@zowe/zos-tso-for-zowe-sdk
Version:
Zowe SDK to interact with TSO on z/OS
94 lines • 4.01 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.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TsoResponseService = void 0;
const imperative_1 = require("@zowe/imperative");
const TsoValidator_1 = require("./TsoValidator");
/**
* Filter responses from z/OSMF
* @export
* @class TsoResponseService
*/
class TsoResponseService {
/**
* Populates start and stop commands response with z/OSMF response details
* @param {IZosmfTsoResponse} zosmfResponse - z/OSMF response object, @see {IZosmfTsoResponse}
* @returns {IStartStopResponse} populated object with type of IStartStopResponse, @see {IStartStopResponse}
* @memberof TsoResponseService
*/
static populateStartAndStop(zosmfResponse) {
TsoValidator_1.TsoValidator.validateStartZosmfResponse(zosmfResponse);
const startResponse = {
success: false,
zosmfTsoResponse: zosmfResponse,
servletKey: zosmfResponse.servletKey
};
if (zosmfResponse.servletKey != null) {
startResponse.success = true;
}
else if (zosmfResponse.msgData) {
startResponse.failureResponse = new imperative_1.ImperativeError({
msg: zosmfResponse.msgData[0].messageText
});
}
return startResponse;
}
/**
* Populates start and stop commands response with z/OSMF response details
* @param {IZosmfTsoResponse} zosmfResponse - z/OSMF response object, @see {IZosmfTsoResponse}
* @param {ICollectedResponses} collectedResponses - collected z/OSMF responses object, @see {ICollectedResponses}
* @returns {IStartStopResponse} populated object with type of IStartStopResponse, @see {IStartStopResponse}
* @memberof TsoResponseService
*/
static populateStartAndStopCollectAll(zosmfResponse, collectedResponses) {
var _a, _b;
TsoValidator_1.TsoValidator.validateStartZosmfResponse(zosmfResponse);
const startResponse = {
success: false,
zosmfTsoResponse: zosmfResponse,
servletKey: zosmfResponse.servletKey,
collectedResponses: (_a = collectedResponses === null || collectedResponses === void 0 ? void 0 : collectedResponses.tsos) !== null && _a !== void 0 ? _a : null,
messages: (_b = collectedResponses === null || collectedResponses === void 0 ? void 0 : collectedResponses.messages) !== null && _b !== void 0 ? _b : ""
};
if (zosmfResponse.servletKey != null) {
startResponse.success = true;
}
else if (zosmfResponse.msgData) {
startResponse.failureResponse = new imperative_1.ImperativeError({
msg: zosmfResponse.msgData[0].messageText
});
}
return startResponse;
}
/**
* Populates ping command response with z/OSMF response details
* @param {IZosmfPingResponse} zosmfResponse - z/OSMF response object, @see {IZosmfPingResponse}
* @returns {PingResponse} populated object with type of IPingResponse
* @memberof TsoResponseService
*/
static populatePing(zosmfResponse) {
TsoValidator_1.TsoValidator.validatePingZosmfResponse(zosmfResponse);
const PingResponse = {
success: false,
zosmfPingResponse: null,
servletKey: null
};
if (zosmfResponse.servletKey != null) {
PingResponse.success = true;
PingResponse.zosmfPingResponse = zosmfResponse;
PingResponse.servletKey = zosmfResponse.servletKey;
}
return PingResponse;
}
}
exports.TsoResponseService = TsoResponseService;
//# sourceMappingURL=TsoResponseService.js.map