// 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. * * Action Service * With the Action service in Splunk Cloud Services, you can receive incoming trigger events and use pre-defined action templates to turn these events into meaningful actions. * * OpenAPI spec version: v1beta2.12 (recommended default) * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import { Action, ActionMutable, ActionResult, ActionResultEmailDetail, PublicWebhookKey, ServiceError, TriggerEvent, } from '../models'; import BaseApiService from "../../../../baseapiservice"; import { ActionServiceExtensions } from "../../../../service_extensions/action"; import { SplunkError, RequestStatus } from '../../../../client'; export const ACTION_SERVICE_PREFIX: string = '/action/v1beta2'; export const ACTION_SERVICE_CLUSTER: string = 'api'; /** * Action Service * Version: v1beta2.12 * With the Action service in Splunk Cloud Services, you can receive incoming trigger events and use pre-defined action templates to turn these events into meaningful actions. */ export class GeneratedActionService extends BaseApiService { getServiceCluster() : string { return ACTION_SERVICE_CLUSTER } getServicePrefix() : string { return ACTION_SERVICE_PREFIX; } /** * Creates an action template. * @param action The action template to create. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Action */ public createAction = (action: Action, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path = `/action/v1beta2/actions`; return this.client.post(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), action, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Action); } /** * Removes an action template. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public deleteAction = (actionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { action_name: actionName }; const path = this.template`/action/v1beta2/actions/${'action_name'}`(path_params); return this.client.delete(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Returns a specific action template. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Action */ public getAction = (actionName: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { action_name: actionName }; const path = this.template`/action/v1beta2/actions/${'action_name'}`(path_params); return this.client.get(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Action); } /** * Returns the status of an action that was invoked. The status is available for 4 days after the last status change. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param statusId The ID of the action status. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return ActionResult */ public getActionStatus = (actionName: string, statusId: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { action_name: actionName, status_id: statusId }; const path = this.template`/action/v1beta2/actions/${'action_name'}/status/${'status_id'}`(path_params); return this.client.get(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as ActionResult); } /** * Returns the status details of the invoked email action. The status is available for 4 days after the last status change. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param statusId The ID of the action status. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Array */ public getActionStatusDetails = (actionName: string, statusId: string, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise> => { const path_params = { action_name: actionName, status_id: statusId }; const path = this.template`/action/v1beta2/actions/${'action_name'}/status/${'status_id'}/details`(path_params); return this.client.get(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Array); } /** * Returns an array of one or two webhook keys. The first key is active. The second key, if present, is expired. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Array */ public getPublicWebhookKeys = (args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise> => { const path = `/system/action/v1beta2/webhook/keys`; return this.client.get(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Array); } /** * Returns the list of action templates. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Array */ public listActions = (args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise> => { const path = `/action/v1beta2/actions`; return this.client.get(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Array); } /** * Invokes an action. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param triggerEvent The action payload, which should include values for any templated fields. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request */ public triggerAction = (actionName: string, triggerEvent: TriggerEvent, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { action_name: actionName }; const path = this.template`/action/v1beta2/actions/${'action_name'}`(path_params); return this.client.post(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), triggerEvent, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as object); } /** * Modifies an action template. * @param actionName The name of the action as one or more identifier strings separated by periods. Each identifier string consists of lowercase letters, digits, and underscores, and cannot start with a digit. * @param actionMutable Updates to the action template. * @param args parameters to be sent with the request * @param requestStatusCallback callback function to listen to the status of a request * @return Action */ public updateAction = (actionName: string, actionMutable: ActionMutable, args?: object, requestStatusCallback?: (requestStatus: RequestStatus) => void): Promise => { const path_params = { action_name: actionName }; const path = this.template`/action/v1beta2/actions/${'action_name'}`(path_params); return this.client.patch(ACTION_SERVICE_CLUSTER, this.client.buildPath('', path.split('/').slice(1)), actionMutable, { query: args, statusCallback: requestStatusCallback}) .then(response => response.body as Action); } } export type ActionService = GeneratedActionService & ActionServiceExtensions; export const ActionService = ActionServiceExtensions(GeneratedActionService);