@zowe/zosmf-for-zowe-sdk
Version:
Zowe SDK to interact with the z/OS Management Facility
84 lines • 3.35 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 });
exports.ZosmfBaseHandler = void 0;
const imperative_1 = require("@zowe/imperative");
const ZosmfSession_1 = require("./ZosmfSession");
/**
* This class is used by the various handlers in the project as the base class for their implementation.
*/
class ZosmfBaseHandler {
/**
* This will grab the arguments and create a session before calling the subclass
* {@link ZosmfBaseHandler#processWithSession} method.
*
* @param {IHandlerParameters} commandParameters Command parameters sent by imperative.
*
* @returns {Promise<void>}
*/
process(commandParameters) {
return __awaiter(this, void 0, void 0, function* () {
this.mHandlerParams = commandParameters;
const sessCfg = ZosmfSession_1.ZosmfSession.createSessCfgFromArgs(commandParameters.arguments);
const sessCfgWithCreds = yield imperative_1.ConnectionPropsForSessCfg.addPropsOrPrompt(sessCfg, commandParameters.arguments, { parms: commandParameters });
this.mSession = new imperative_1.Session(sessCfgWithCreds);
this.mArguments = commandParameters.arguments;
yield this.processCmd(commandParameters);
});
}
/**
* Fail the command with an imperative error
* @param {IImperativeError} err - the imperative error parameters
*/
fail(err) {
throw new imperative_1.ImperativeError(err);
}
/**
* Returns the console interface for the command handler
* @returns {IHandlerResponseConsoleApi}
*/
get console() {
return this.mHandlerParams.response.console;
}
/**
* Returns the format interface for the command handler
* @returns {IHandlerFormatOutputApi}
*/
get format() {
return this.mHandlerParams.response.format;
}
/**
* Returns the format interface for the command handler
* @returns {IHandlerResponseDataApi}
*/
get data() {
return this.mHandlerParams.response.data;
}
/**
* Returns the format interface for the command handler
* @returns {IHandlerProgressApi}
*/
get progress() {
return this.mHandlerParams.response.progress;
}
}
exports.ZosmfBaseHandler = ZosmfBaseHandler;
//# sourceMappingURL=ZosmfBaseHandler.js.map