// tslint:disable /** * Copyright 2022 Splunk, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"): you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * * Splunk Search service * Use the Search service in Splunk Cloud Services to dispatch, review, and manage searches and search jobs. You can finalize or cancel jobs, retrieve search results, and request search-related configurations from the Metadata Catalog service in Splunk Cloud Services. * * OpenAPI spec version: v3alpha1 * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import { Dataset, DatasetPATCH, DatasetPOST, DeleteSearchJob, FederatedConnection, FederatedConnectionInput, FieldsSummary, ListDatasets, ListFederatedConnections, ListModules, ListPreviewResultsResponse, ListSearchResultsResponse, Module, SearchJob, SearchModule, SearchStatus, TimeBucketsSummary, UpdateJob, } from '../models'; import BaseApiService from "../../../../baseapiservice"; import { SearchServiceExtensions } from "../../../../service_extensions/search"; import { SplunkError, RequestStatus } from '../../../../client'; export const SEARCH_SERVICE_PREFIX: string = '/search/v3alpha1'; export const SEARCH_SERVICE_CLUSTER: string = 'api'; /** * @export */ export enum OutputModeEnum { Csv = 'csv', Json = 'json' } /** * Splunk Search service * Version: v3alpha1 * Use the Search service in Splunk Cloud Services to dispatch, review, and manage searches and search jobs. You can finalize or cancel jobs, retrieve search results, and request search-related configurations from the Metadata Catalog service in Splunk Cloud Services. */ export class GeneratedSearchService extends BaseApiService { getServiceCluster() : string { return SEARCH_SERVICE_CLUSTER } getServicePrefix() : string { return SEARCH_SERVICE_PREFIX; } /** * Creates a dataset. * @param datasetPOST * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Dataset */ public createDataset = (datasetPOST?: DatasetPOST, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!datasetPOST) { throw new SplunkError({ message: `Bad Request: datasetPOST is empty or undefined` }); } const path = `/search/v3alpha1/datasets`; return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), datasetPOST, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Dataset); } /** * Creates a new federated connection with information about how to connect to a remote index. * @param federatedConnectionInput * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return FederatedConnection */ public createFederatedConnection = (federatedConnectionInput?: FederatedConnectionInput, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!federatedConnectionInput) { throw new SplunkError({ message: `Bad Request: federatedConnectionInput is empty or undefined` }); } const path = `/search/v3alpha1/connections`; return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), federatedConnectionInput, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as FederatedConnection); } /** * Creates a search job. * @param searchJob * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return SearchJob */ public createJob = (searchJob?: SearchJob, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!searchJob) { throw new SplunkError({ message: `Bad Request: searchJob is empty or undefined` }); } const path = `/search/v3alpha1/jobs`; return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), searchJob, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as SearchJob); } /** * Create a multi-statement module with inter-dependencies between statements. * @param searchModule * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return SearchModule */ public createSearchStatements = (searchModule?: SearchModule, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!searchModule) { throw new SplunkError({ message: `Bad Request: searchModule is empty or undefined` }); } const path = `/search/v3alpha1/dispatch`; return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), searchModule, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as SearchModule); } /** * Modifies/Creates a module with a specified resource name (resourceName). * @param resourceName The resource name. * @param module * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Module */ public createSpl2Module = (resourceName: string, module?: Module, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!module) { throw new SplunkError({ message: `Bad Request: module is empty or undefined` }); } const path_params = { resourceName: resourceName }; const path = this.template`/search/v3alpha1/spl2-modules/${'resourceName'}`(path_params); return this.client.put(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), module, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Module); } /** * Deletes a dataset with a specified dataset ID (datasetid). * @param datasetid The dataset ID. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public deleteDatasetById = (datasetid: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { datasetid: datasetid }; const path = this.template`/search/v3alpha1/datasets/${'datasetid'}`(path_params); return this.client.delete(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Deletes a federated connection with the specified name (connectionName) * @param connectionName The name of the federated connection. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public deleteFederatedConnection = (connectionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { connectionName: connectionName }; const path = this.template`/search/v3alpha1/connections/${'connectionName'}`(path_params); return this.client.delete(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Creates a search job that deletes events from an index. The events are deleted from the index in the specified module, based on the search criteria as specified by the predicate. * @param deleteSearchJob * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return DeleteSearchJob */ public deleteJob = (deleteSearchJob?: DeleteSearchJob, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!deleteSearchJob) { throw new SplunkError({ message: `Bad Request: deleteSearchJob is empty or undefined` }); } const path = `/search/v3alpha1/jobs/delete`; return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), deleteSearchJob, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as DeleteSearchJob); } /** * Deletes a module with a specified resource name (resourceName). * @param resourceName The resource name. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Module */ public deleteSpl2ModuleByResourceName = (resourceName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { resourceName: resourceName }; const path = this.template`/search/v3alpha1/spl2-modules/${'resourceName'}`(path_params); return this.client.delete(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Module); } /** * Export the search results for the job with the specified search ID (SID). Export the results as a csv file or json file. * @param sid The search ID. * @param args parameters to be sent with the request * @param args.count The maximum number of entries to return. Set to 0 to return all available entries. * @param args.filename The export results filename. Default: exportResults * @param args.outputMode Specifies the format for the returned output. * @param requestStatusCallback callback function to listen to the status of a request * @return { [key: string]: any; } */ public exportResults = (sid: string, args?: { count?: number, filename?: string, outputMode?: OutputModeEnum, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise<{ [key: string]: any; }> => { const path_params = { sid: sid }; const path = this.template`/search/v2beta1/jobs/${'sid'}/export`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as { [key: string]: any; }); } /** * Returns all federated connections. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return ListFederatedConnections */ public getAllFederatedConnections = (args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path = `/search/v3alpha1/connections`; return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListFederatedConnections); } /** * Returns a dataset with a specified dataset ID (datasetid). * @param datasetid The dataset ID. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Dataset */ public getDatasetById = (datasetid: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { datasetid: datasetid }; const path = this.template`/search/v3alpha1/datasets/${'datasetid'}`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Dataset); } /** * Returns the federated connection with the specified name (connectionName). * @param connectionName The name of the federated connection. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return FederatedConnection */ public getFederatedConnectionByName = (connectionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { connectionName: connectionName }; const path = this.template`/search/v3alpha1/connections/${'connectionName'}`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as FederatedConnection); } /** * Returns a search job with a specified search ID (sid). * @param sid The search ID. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return SearchJob */ public getJob = (sid: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as SearchJob); } /** * Returns a module with a specified resource name (resourceName). * @param resourceName The resource name. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Module */ public getSpl2ModuleByResourceName = (resourceName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { resourceName: resourceName }; const path = this.template`/search/v3alpha1/spl2-modules/${'resourceName'}`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Module); } /** * Returns a list of all datasets. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return ListDatasets */ public listDatasets = (args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path = `/search/v3alpha1/datasets`; return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListDatasets); } /** * Return events summary, for search ID (SID) search. * @param sid The search ID. * @param args parameters to be sent with the request * @param args.count The maximum number of entries to return. Set to 0 to return all available entries. * @param args.earliest The earliest time filter, in absolute time. When specifying an absolute time specify either UNIX time, or UTC in seconds using the ISO-8601 (%FT%T.%Q) format. For example 2019-01-25T13:15:30Z. GMT is the default timezone. You must specify GMT when you specify UTC. Any offset specified is ignored. * @param args.field The field to return for the result set. Specify multiple fields of comma-separated values if multiple fields are required. * @param args.latest The latest time filter, in absolute time. When specifying an absolute time specify either UNIX time, or UTC in seconds using the ISO-8601 (%FT%T.%Q) format. For example 2019-01-25T13:15:30Z. GMT is the default timezone. You must specify GMT when you specify UTC. Any offset specified is ignored. Latest time must be after Earliest time. * @param args.offset The index of the first item to return. * @param requestStatusCallback callback function to listen to the status of a request * @return ListSearchResultsResponse */ public listEventsSummary = (sid: string, args?: { count?: number, earliest?: string, field?: string, latest?: string, offset?: number, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}/timeline-metadata/auto/events-summary`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListSearchResultsResponse); } /** * Return fields stats summary of the events to-date, for search ID (SID) search. * @param sid The search ID. * @param args parameters to be sent with the request * @param args.earliest The earliest time filter, in absolute time. When specifying an absolute time specify either UNIX time, or UTC in seconds using the ISO-8601 (%FT%T.%Q) format. For example 2019-01-25T13:15:30Z. GMT is the default timezone. You must specify GMT when you specify UTC. Any offset specified is ignored. * @param args.latest The latest time filter, in absolute time. When specifying an absolute time specify either UNIX time, or UTC in seconds using the ISO-8601 (%FT%T.%Q) format. For example 2019-01-25T13:15:30Z. GMT is the default timezone. You must specify GMT when you specify UTC. Any offset specified is ignored. Latest time must be after Earliest time. * @param requestStatusCallback callback function to listen to the status of a request * @return FieldsSummary */ public listFieldsSummary = (sid: string, args?: { earliest?: string, latest?: string, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}/timeline-metadata/auto/fields-summary`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as FieldsSummary); } /** * Returns a matching list of search jobs. * @param args parameters to be sent with the request * @param args.count The maximum number of jobs that you want to return the status entries for. * @param args.filter Filter the list of jobs by sid. Valid format is `sid IN ({comma separated list of SIDs in quotes})`. A maximum of 30 SIDs can be specified in one query. * @param args.status Filter the list of jobs by status. Valid status values are 'running', 'done', 'canceled', or 'failed'. * @param requestStatusCallback callback function to listen to the status of a request * @return Array */ public listJobs = (args?: { count?: number, filter?: string, status?: SearchStatus, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise> => { const path = `/search/v3alpha1/jobs`; return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Array); } /** * Return the preview search results for the job with the specified search ID (SID). Can be used when a job is running to return interim results. * @param sid The search ID. * @param args parameters to be sent with the request * @param args.count The maximum number of entries to return. Set to 0 to return all available entries. * @param args.offset The index of the first item to return. * @param requestStatusCallback callback function to listen to the status of a request * @return ListPreviewResultsResponse */ public listPreviewResults = (sid: string, args?: { count?: number, offset?: number, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}/results-preview`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListPreviewResultsResponse); } /** * Returns search results for a job with a specified search ID (sid). * @param sid The search ID. * @param args parameters to be sent with the request * @param args.count The maximum number of entries to return. Set to 0 to return all available entries. * @param args.field The field to return for the result set. Specify multiple fields of comma-separated values if multiple fields are required. * @param args.offset The index of the first item to return. * @param requestStatusCallback callback function to listen to the status of a request * @return ListSearchResultsResponse */ public listResults = (sid: string, args?: { count?: number, field?: string, offset?: number, [key: string]: any }, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}/results`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListSearchResultsResponse); } /** * gets a list of modules. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return ListModules */ public listSpl2Modules = (args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path = `/search/v3alpha1/spl2-modules`; return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ListModules); } /** * Returns an event distribution over time of the untransformed events that are read to-date for a job with a specified search ID (sid). * @param sid The search ID. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return TimeBucketsSummary */ public listTimeBuckets = (sid: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}/timeline-metadata/auto/time-buckets`(path_params); return this.client.get(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as TimeBucketsSummary); } /** * Creates or updates a federated connection with a specified name (connectionName). * @param connectionName The name of the federated connection. * @param federatedConnectionInput * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return FederatedConnection */ public putFederatedConnectionByName = (connectionName: string, federatedConnectionInput?: FederatedConnectionInput, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!federatedConnectionInput) { throw new SplunkError({ message: `Bad Request: federatedConnectionInput is empty or undefined` }); } const path_params = { connectionName: connectionName }; const path = this.template`/search/v3alpha1/connections/${'connectionName'}`(path_params); return this.client.put(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), federatedConnectionInput, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as FederatedConnection); } /** * Refresh a federated connection to fetch new remote indexes and add/delete corresponding federated datasets. * @param connectionName The name of the federated connection. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public refreshFederatedConnection = (connectionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { connectionName: connectionName }; const path = this.template`/search/v3alpha1/connections/${'connectionName'}/refresh`(path_params); return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Test connection with remote EC instance using federated connection parameters. * @param connectionName The name of the federated connection. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public testFederatedConnection = (connectionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { connectionName: connectionName }; const path = this.template`/search/v3alpha1/connections/${'connectionName'}/test`(path_params); return this.client.post(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Modifies a dataset with a specified dataset ID (datasetid). * @param datasetid The dataset ID. * @param datasetPATCH * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Dataset */ public updateDatasetById = (datasetid: string, datasetPATCH?: DatasetPATCH, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!datasetPATCH) { throw new SplunkError({ message: `Bad Request: datasetPATCH is empty or undefined` }); } const path_params = { datasetid: datasetid }; const path = this.template`/search/v3alpha1/datasets/${'datasetid'}`(path_params); return this.client.patch(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), datasetPATCH, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Dataset); } /** * Modifies a search job with a specified search ID (sid) with an action. * @param sid The search ID. * @param updateJob * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return SearchJob */ public updateJob = (sid: string, updateJob?: UpdateJob, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { if (!updateJob) { throw new SplunkError({ message: `Bad Request: updateJob is empty or undefined` }); } const path_params = { sid: sid }; const path = this.template`/search/v3alpha1/jobs/${'sid'}`(path_params); return this.client.patch(SEARCH_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), updateJob, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as SearchJob); } } export type SearchService = GeneratedSearchService & SearchServiceExtensions; export const SearchService = SearchServiceExtensions(GeneratedSearchService);