@zowe/cli
Version:
Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.
99 lines • 4.59 kB
JavaScript
;
/*
* 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 CancelJobs
*/
class CancelJobs {
/**
* 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 CancelJobs
*/
static cancelJob(session, jobname, jobid, version) {
return __awaiter(this, void 0, void 0, function* () {
this.log.trace("cancelJob called with jobname %s jobid %s", jobname, jobid);
return CancelJobs.cancelJobCommon(session, { jobname, jobid });
});
}
/**
* Cancel and purge a job
* Alternative version of the cancel 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 cancel
* @param {string} version - version of cancel request
* @returns {Promise<void>} - promise that resolves when the API call is complete
* @memberof CancelJobs
*/
static cancelJobForJob(session, job, version) {
return __awaiter(this, void 0, void 0, function* () {
this.log.trace("cancelJobForJob called with job %s", JSON.stringify(job));
return CancelJobs.cancelJobCommon(session, { jobname: job.jobname, jobid: job.jobid, version });
});
}
/**
* Cancel and purge a job
* Full version of the API with a parameter object
* @static
* @param {AbstractSession} session - z/OSMF connection info
* @param {ICancelJobParms} parms - parm object (see ICancelJobParms interface for details)
* @returns {Promise<void>} - promise that resolves when the API call is complete
* @memberof CancelJobs
*/
static cancelJobCommon(session, parms) {
return __awaiter(this, void 0, void 0, function* () {
this.log.trace("cancelJobCommon 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 cancel.");
// set default if unset
if (parms.version == null) {
parms.version = JobsConstants_1.JobsConstants.DEFAULT_CANCEL_VERSION;
}
this.log.info("Canceling job %s(%s). Job modify version?: %s", parms.jobname, parms.jobid, parms.version);
const headers = [imperative_1.Headers.APPLICATION_JSON];
// build request
const request = {
request: JobsConstants_1.JobsConstants.REQUEST_CANCEL,
version: parms.version,
};
const parameters = "/" + parms.jobname + "/" + parms.jobid;
yield rest_1.ZosmfRestClient.putExpectString(session, JobsConstants_1.JobsConstants.RESOURCE + parameters, headers, request);
});
}
/**
* Getter for brightside logger
* @returns {Logger}
*/
static get log() {
return imperative_1.Logger.getAppLogger();
}
}
exports.CancelJobs = CancelJobs;
//# sourceMappingURL=CancelJobs.js.map