import { AbstractSession , ICommandArguments , ICommandHandler , IHandlerParameters , IProfile , IHandlerResponseConsoleApi , IHandlerFormatOutputApi , IHandlerResponseDataApi , IHandlerProgressApi , IImperativeError , ImperativeError , IProfileLoaded , ISession , Session , ConnectionPropsForSessCfg } from "@zowe/imperative" ; import { ZosmfSession } from "./ZosmfSession" ; /**
 * This class is used by the various handlers in the project as the base class for their implementation.
 */ export abstract class ZosmfBaseHandler implements ICommandHandler { /**
     * The session creating from the command line arguments / profile
     */ protected mSession : AbstractSession ; /**
     * Loaded z/OSMF profile if needed
     */ protected mZosmfProfile : IProfile ; /**
     * Loaded z/OSMF profile with meta information
     */ protected mZosmfLoadedProfile : IProfileLoaded ; /**
     * Command line arguments passed
     */ protected mArguments : ICommandArguments ; /**
     * Full set of command handler parameters from imperative
     */ protected mHandlerParams : IHandlerParameters ; /**
     * This will grab the arguments and create a session before calling the subclass
     *  ZosmfBaseHandler method.
     *
     *  param { IHandlerParameters } commandParameters returns { Promise < void > } public async process ( commandParameters ) { this . mHandlerParams = commandParameters ; this . mZosmfProfile = commandParameters . profiles . get ( "zosmf" , false ) ; this . mZosmfLoadedProfile = commandParameters . profiles . getMeta ( "zosmf" , false ) ; const sessCfg = ZosmfSession . createSessCfgFromArgs ( commandParameters . arguments ) ; const sessCfgWithCreds = await ConnectionPropsForSessCfg . addPropsOrPrompt < ISession > ( sessCfg , commandParameters . arguments ) ; this . mSession = new Session ( sessCfgWithCreds ) ; this . mArguments = commandParameters . arguments ; await this . processCmd ( commandParameters ) ; } param { IImperativeError } err public fail ( err ) { throw new ImperativeError ( err ) ; } returns { IHandlerResponseConsoleApi } public get console ( ) : IHandlerResponseConsoleApi { return this . mHandlerParams . response . console ; } returns { IHandlerFormatOutputApi } public get format ( ) : IHandlerFormatOutputApi { return this . mHandlerParams . response . format ; } returns { IHandlerResponseDataApi } public get data ( ) : IHandlerResponseDataApi { return this . mHandlerParams . response . data ; } returns { IHandlerProgressApi } public get progress ( ) : IHandlerProgressApi { return this . mHandlerParams . response . progress ; } /**
     * This is called by the  ZosmfBaseHandler after it creates a session.
     *
     *  param { IHandlerParameters } commandParameters public abstract async processCmd ( commandParameters ) ; }