UNPKG

@zowe/imperative

Version:
58 lines 2.65 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. * */ 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.AbstractAuthHandler = void 0; const constants_1 = require("../../../../constants"); const error_1 = require("../../../../error"); /** * This class is used by the auth command handlers as the base class for their implementation. */ class AbstractAuthHandler { /** * This handler is used for both "auth login" and "auth logout" commands. * It determines the correct action to take and calls either `processLogin` * or `processLogout` accordingly. * * @param {IHandlerParameters} commandParameters Command parameters sent by imperative. * * @returns {Promise<void>} */ process(commandParameters) { return __awaiter(this, void 0, void 0, function* () { switch (commandParameters.positionals[1]) { case constants_1.Constants.LOGIN_ACTION: case constants_1.Constants.LOGIN_ACTION_ALIAS: yield this.processLogin(commandParameters); break; case constants_1.Constants.LOGOUT_ACTION: case constants_1.Constants.LOGOUT_ACTION_ALIAS: yield this.processLogout(commandParameters); break; default: throw new error_1.ImperativeError({ msg: `The group name "${commandParameters.positionals[1]}" was passed to the AbstractAuthHandler, but it is not valid.` }); } }); } } exports.AbstractAuthHandler = AbstractAuthHandler; //# sourceMappingURL=AbstractAuthHandler.js.map