UNPKG

@zowe/cli

Version:

Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.

97 lines 4.72 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const imperative_1 = require("@zowe/imperative"); const JobsConstants_1 = require("./JobsConstants"); const rest_1 = require("../../../rest"); /** * Class to handle deletion of job information * @export * @class DeleteJobs */ class DeleteJobs { /** * Cancel and purge a job * @static * @param {AbstractSession} session - z/OSMF connection info * @param {string} jobname - job name to be translated into parms object * @param {string} jobid - job id to be translated into parms object * @returns {Promise<void>} - promise that resolves when the API call is complete * @memberof DeleteJobs */ static deleteJob(session, jobname, jobid) { return __awaiter(this, void 0, void 0, function* () { this.log.trace("deleteJob called with jobname %s jobid %s", jobname, jobid); return DeleteJobs.deleteJobCommon(session, { jobname, jobid }); }); } /** * Cancel and purge a job * Alternative version of the delete API accepting an IJob object returned from other APIs such as GetJobs and SubmitJobs * @static * @param {AbstractSession} session - z/OSMF connection info * @param {IJob} job - the job that you want to delete * @param {"1.0"| "2.0"} modifyVersion - version of the X-IBM-Job-Modify-Version header to use (see ZosmfHeaders) * @returns {Promise<void>} - promise that resolves when the API call is completel * @memberof DeleteJobs */ static deleteJobForJob(session, job, modifyVersion) { return __awaiter(this, void 0, void 0, function* () { this.log.trace("deleteJobForJob called with job %s", JSON.stringify(job)); return DeleteJobs.deleteJobCommon(session, { jobname: job.jobname, jobid: job.jobid, modifyVersion }); }); } /** * Cancel and purge a job * Full version of the API with a parameter object * @static * @param {AbstractSession} session - z/OSMF connection info * @param {IDeleteJobParms} parms - parm object (see IDeleteJobParms interface for details) * @returns {Promise<void>} - promise that resolves when the API call is complete * @memberof DeleteJobs */ static deleteJobCommon(session, parms) { return __awaiter(this, void 0, void 0, function* () { this.log.trace("deleteJobCommon called with parms %s", JSON.stringify(parms)); imperative_1.ImperativeExpect.keysToBeDefinedAndNonBlank(parms, ["jobname", "jobid"], "You must specify jobname and jobid for the job you want to delete."); this.log.info("Deleting job %s (%s). Job modify version?: %s", parms.jobname, parms.jobid, parms.modifyVersion + ""); const headers = []; // check the desired version of the job modify header - influences whether the API is synchronous or asynchronous if (parms.modifyVersion === "1.0") { headers.push(rest_1.ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_1); } else if (parms.modifyVersion === "2.0") { headers.push(rest_1.ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); } const parameters = imperative_1.IO.FILE_DELIM + parms.jobname + imperative_1.IO.FILE_DELIM + parms.jobid; yield rest_1.ZosmfRestClient.deleteExpectString(session, JobsConstants_1.JobsConstants.RESOURCE + parameters, headers); }); } /** * Getter for brightside logger * @returns {Logger} */ static get log() { return imperative_1.Logger.getAppLogger(); } } exports.DeleteJobs = DeleteJobs; //# sourceMappingURL=DeleteJobs.js.map