UNPKG

@zowe/zos-jobs-for-zowe-sdk

Version:
106 lines 5.3 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 }); exports.DeleteJobs = void 0; const imperative_1 = require("@zowe/imperative"); const JobsConstants_1 = require("./JobsConstants"); const core_for_zowe_sdk_1 = require("@zowe/core-for-zowe-sdk"); /** * 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<undefined|IJobFeedback>} - promise of undefined, or IJobFeedback object returned by API if modifyVersion is 2.0 * @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<undefined|IJobFeedback>} - promise of undefined, or IJobFeedback object returned by API if modifyVersion is 2.0 * @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<undefined|IJobFeedback>} - promise of undefined, or IJobFeedback object returned by API if modifyVersion is 2.0 * @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(core_for_zowe_sdk_1.ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_1); } else { headers.push(core_for_zowe_sdk_1.ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); } const responseJson = yield core_for_zowe_sdk_1.ZosmfRestClient.deleteExpectJSON(session, imperative_1.EncodeUri.encUriPathForZos(session, JobsConstants_1.JobsConstants.RESOURCE + "/" + parms.jobname + "/" + parms.jobid), headers); if (parms.modifyVersion === "1.0") { return undefined; } else { const responseFeedback = responseJson; // Turns out status is a number, but we cannot introduce breaking changes. responseFeedback.status = responseFeedback.status.toString(); return responseFeedback; } }); } /** * Getter for Zowe logger * @returns {Logger} */ static get log() { return imperative_1.Logger.getAppLogger(); } } exports.DeleteJobs = DeleteJobs; //# sourceMappingURL=DeleteJobs.js.map