import { AbstractSession , ImperativeExpect , Logger , Headers } from "@zowe/imperative" ; import { JobsConstants } from "./JobsConstants" ; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk" ; import { IJob } from "./doc/response/IJob" ; import { ICancelJobParms } from "./doc/input/ICancelJobParms" ; import { ICancelJob } from "./doc/input/ICancelJob" ; export class export class CancelJobs { static param { AbstractSession } session param { string } jobname param { string } jobid returns { Promise < void > } memberof public static async cancelJob ( session , jobname , jobid , version ? ) { this . log . trace ( "cancelJob called with jobname %s jobid %s" , jobname , jobid ) ; return CancelJobs . cancelJobCommon ( session , { jobname , jobid } ) ; } static param { AbstractSession } session param { IJob } job param { string } version returns { Promise < void > } memberof public static async cancelJobForJob ( session , job , version ? ) { this . log . trace ( "cancelJobForJob called with job %s" , JSON . stringify ( job ) ) ; return CancelJobs . cancelJobCommon ( session , { jobname : job . jobname , jobid : job . jobid , version } ) ; } static param { AbstractSession } session param { ICancelJobParms } parms returns { Promise < void > } memberof public static async cancelJobCommon ( session , parms ) { this . log . trace ( "cancelJobCommon called with parms %s" , JSON . stringify ( parms ) ) ; ImperativeExpect . keysToBeDefinedAndNonBlank ( parms , [ "jobname" , "jobid" ] , "You must specify jobname and jobid for the job you want to cancel." ) ; if ( parms . version == null ) { parms . version = JobsConstants . DEFAULT_CANCEL_VERSION ; } this . log . info ( "Canceling job %s(%s). Job modify version?: %s" , parms . jobname , parms . jobid , parms . version ) ; const headers = [ Headers . APPLICATION_JSON ] ; const request = { request : JobsConstants . REQUEST_CANCEL , version : parms . version } ; const parameters = "/" + parms . jobname + "/" + parms . jobid ; await ZosmfRestClient . putExpectString ( session , JobsConstants . RESOURCE + parameters , headers , request ) ; } returns { Logger } private static get log ( ) : Logger { return Logger . getAppLogger ( ) ; } }