UNPKG

@zowe/cics-for-zowe-cli

Version:
161 lines 5.86 kB
"use strict"; /** * 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. * */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CicsSession = void 0; const imperative_1 = require("@zowe/imperative"); /** * Utility Methods for Zowe * @export */ class CicsSession { static CICS_CONNECTION_OPTION_GROUP = "Cics Connection Options"; /** * Option used in profile creation and commands for hostname for CICS */ static CICS_OPTION_HOST = { name: "host", aliases: ["H"], description: "The CICS server host name.", type: "string", group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Option used in profile creation and commands for port for CICS */ static CICS_OPTION_PORT = { name: "port", aliases: ["P"], description: "The CICS server port.", type: "number", defaultValue: 443, group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Option used in profile creation and commands for username / ID for CICS */ static CICS_OPTION_USER = { name: "user", aliases: ["u"], description: "Mainframe (CICS) user name, which can be the same as your TSO login.", type: "string", group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Option used in profile creation and commands for password/passphrase for CICS */ static CICS_OPTION_PASSWORD = { name: "password", aliases: ["pw"], description: "Mainframe (CICS) password, which can be the same as your TSO password.", type: "string", group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Option used in profile creation and commands for rejectUnauthorized setting for connecting to FMP */ static CICS_OPTION_REJECT_UNAUTHORIZED = { name: "reject-unauthorized", aliases: ["ru"], description: "Reject self-signed certificates.", type: "boolean", defaultValue: true, group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Option used in profile creation and commands for protocol for CMCI */ static CICS_OPTION_PROTOCOL = { name: "protocol", aliases: ["o"], description: "Specifies CMCI protocol (http or https).", type: "string", defaultValue: "https", allowableValues: { values: ["http", "https"], caseSensitive: false }, group: CicsSession.CICS_CONNECTION_OPTION_GROUP, }; /** * Options related to connecting to CICS * These options can be filled in if the user creates a profile */ static CICS_CONNECTION_OPTIONS = [ CicsSession.CICS_OPTION_HOST, CicsSession.CICS_OPTION_PORT, CicsSession.CICS_OPTION_USER, CicsSession.CICS_OPTION_PASSWORD, CicsSession.CICS_OPTION_REJECT_UNAUTHORIZED, CicsSession.CICS_OPTION_PROTOCOL, ]; /** * Given a CICS profile, create a REST Client Session. * @static * @param {IProfile} profile - The CICS profile contents * @returns {Session} - A session for usage in the CMCI REST Client */ static createBasicCicsSession(profile) { this.log.debug("Creating a CICS session from the profile named %s", profile.name); return new imperative_1.Session({ type: "basic", hostname: profile.host, port: profile.port, user: profile.user, password: profile.pass, basePath: profile.basePath, protocol: profile.protocol || "https", }); } /** * Given command line arguments, create a REST Client Session. * @static * @param {IProfile} args - The arguments specified by the user * @returns {Session} - A session for usage in the CMCI REST Client */ static createBasicCicsSessionFromArguments(args) { this.log.debug("Creating a CICS session from arguments"); return new imperative_1.Session({ type: "basic", hostname: args.host, port: args.port, user: args.user, password: args.password, basePath: args.basePath, rejectUnauthorized: args.rejectUnauthorized, protocol: args.protocol || "https", }); } /** * Given command line arguments, create a REST Client Session. * @static * @param {IProfile} args - The arguments specified by the user * @param {boolean} doPrompting - Whether to prompt for missing arguments (defaults to true) * @param {IHandlerParameters} handlerParams - The command parameters object for Daemon mode prompting * @returns {Session} - A session for usage in the CMCI REST Client */ static async createSessCfgFromArgs(args, doPrompting = true, handlerParams) { const sessCfg = { type: "basic", hostname: args.host, port: args.port, user: args.user, password: args.password, basePath: args.basePath, rejectUnauthorized: args.rejectUnauthorized, protocol: args.protocol || "https", }; const sessCfgWithCreds = await imperative_1.ConnectionPropsForSessCfg.addPropsOrPrompt(sessCfg, args, { doPrompting, parms: handlerParams }); return new imperative_1.Session(sessCfgWithCreds); } static get log() { return imperative_1.Logger.getAppLogger(); } } exports.CicsSession = CicsSession; //# sourceMappingURL=CicsSession.js.map