import { AbstractSession , ImperativeExpect , IO , Logger } from "@zowe/imperative" ; import { JobsConstants } from "./JobsConstants" ; import { ZosmfHeaders , ZosmfRestClient } from "@zowe/core-for-zowe-sdk" ; import { IJob } from "./doc/response/IJob" ; import { IDeleteJobParms } from "./doc/input/IDeleteJobParms" ; export class export class DeleteJobs { static param { AbstractSession } session param { string } jobname param { string } jobid returns { Promise < void > } memberof public static async deleteJob ( session , jobname , jobid ) { this . log . trace ( "deleteJob called with jobname %s jobid %s" , jobname , jobid ) ; return DeleteJobs . deleteJobCommon ( session , { jobname , jobid } ) ; } static param { AbstractSession } session param { IJob } job param { "1.0" | "2.0" } modifyVersion returns { Promise < void > } memberof public static async deleteJobForJob ( session , job , modifyVersion ? ) { this . log . trace ( "deleteJobForJob called with job %s" , JSON . stringify ( job ) ) ; return DeleteJobs . deleteJobCommon ( session , { jobname : job . jobname , jobid : job . jobid , modifyVersion } ) ; } static param { AbstractSession } session param { IDeleteJobParms } parms returns { Promise < void > } memberof public static async deleteJobCommon ( session , parms ) { this . log . trace ( "deleteJobCommon called with parms %s" , JSON . stringify ( parms ) ) ; 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 = [ ] ; if ( parms . modifyVersion === "2.0" ) { headers . push ( ZosmfHeaders . X_IBM_JOB_MODIFY_VERSION_2 ) ; } else { headers . push ( ZosmfHeaders . X_IBM_JOB_MODIFY_VERSION_1 ) ; } const parameters = IO . FILE_DELIM + parms . jobname + IO . FILE_DELIM + parms . jobid ; await ZosmfRestClient . deleteExpectString ( session , JobsConstants . RESOURCE + parameters , headers ) ; } returns { Logger } private static get log ( ) : Logger { return Logger . getAppLogger ( ) ; } }