UNPKG

@zowe/cli

Version:

Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.

78 lines 3.95 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 }); const imperative_1 = require("@zowe/imperative"); const rest_1 = require("../../../rest"); const TsoConstants_1 = require("./TsoConstants"); const TsoValidator_1 = require("./TsoValidator"); const TsoResponseService_1 = require("./TsoResponseService"); /** * Stop active TSO address space using servlet key * @export * @class StopTso */ class StopTso { /** * Sends REST call to z/OSMF for stoping active TSO address space * @param {AbstractSession} session - z/OSMF connection info * @param {IStopTsoParms} commandParms - object with required parameters, @see {IStopTsoParms} * @returns {Promise<IZosmfTsoResponse>} z/OSMF response object, @see {IZosmfTsoResponse} * @memberOf StopTso */ static stopCommon(session, commandParms) { return __awaiter(this, void 0, void 0, function* () { TsoValidator_1.TsoValidator.validateSession(session); TsoValidator_1.TsoValidator.validateStopParams(commandParms); TsoValidator_1.TsoValidator.validateNotEmptyString(commandParms.servletKey, TsoConstants_1.noServletKeyInput.message); const resources = this.getResources(commandParms.servletKey); return rest_1.ZosmfRestClient.deleteExpectJSON(session, resources, [rest_1.ZosmfHeaders.X_CSRF_ZOSMF_HEADER, imperative_1.Headers.APPLICATION_JSON]); }); } /** * Stop TSO address space and populates response with IStartStopResponse, @see {IStartStopResponse} * @param {AbstractSession} session * @param {string} servKey - unique servlet entry identifier * @returns {Promise<IStartStopResponse>} populated response, @see {IStartStopResponse} * @memberOf StopTso */ static stop(session, servKey) { return __awaiter(this, void 0, void 0, function* () { TsoValidator_1.TsoValidator.validateSession(session); TsoValidator_1.TsoValidator.validateNotEmptyString(servKey, TsoConstants_1.noServletKeyInput.message); const commandParms = { servletKey: servKey }; const zosmfResponse = yield this.stopCommon(session, commandParms); TsoValidator_1.TsoValidator.validateErrorMessageFromZosmf(zosmfResponse); return TsoResponseService_1.TsoResponseService.populateStartAndStop(zosmfResponse); }); } /** * Generates query parameter needed for z/OSMF REST call * @param {string} servletKey - unique servlet entry identifier * @returns {string} generated resources query * @memberOf StopTso */ static getResources(servletKey) { TsoValidator_1.TsoValidator.validateNotEmptyString(servletKey, TsoConstants_1.noServletKeyInput.message); return `${TsoConstants_1.TsoConstants.RESOURCE}/${TsoConstants_1.TsoConstants.RES_START_TSO}/${servletKey}`; } } exports.StopTso = StopTso; //# sourceMappingURL=StopTso.js.map