import { AbstractSession , ICommandHandler , IHandlerParameters , IProfile , ImperativeError , ConnectionPropsForSessCfg , ISession , Session } from "@zowe/imperative" ; import { IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk" ; import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk" ; private export abstract class ZosFilesBaseHandler implements ICommandHandler { /**
     * This will grab the zosmf profile and create a session before calling the subclass
     *  ZosFilesBaseHandler method.
     *
     *  param { IHandlerParameters } commandParameters returns { Promise < void > } public async process ( commandParameters ) { const profile = commandParameters . profiles . get ( "zosmf" , false ) ; const sessCfg = ZosmfSession . createSessCfgFromArgs ( commandParameters . arguments ) ; const sessCfgWithCreds = await ConnectionPropsForSessCfg . addPropsOrPrompt < ISession > ( sessCfg , commandParameters . arguments ) ; const session = new Session ( sessCfgWithCreds ) ; const response = await this . processWithSession ( commandParameters , session , profile ) ; commandParameters . response . progress . endBar ( ) ; if ( response . commandResponse ) { commandParameters . response . console . log ( response . commandResponse ) ; } commandParameters . response . data . setObj ( response ) ; if ( ! response . success && response . commandResponse ) { throw new ImperativeError ( { msg : response . commandResponse } ) ; } } /**
     * This is called by the  ZosFilesBaseHandler after it creates a session. Should
     * be used so that every class under files does not have to instantiate the session object.
     *
     *  param { IHandlerParameters } commandParameters param { AbstractSession } session param { IProfile } zosmfProfile returns { Promise < IZosFilesResponse > } public abstract async processWithSession ( commandParameters , session , zosmfProfile ) ; }