@zosconnect/zosconnect-zowe-cli
Version:
z/OS Connect EE Plugin for Zowe CLI
71 lines • 3.49 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 IBM 2019
*
*/
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 fs = require("fs");
const got_1 = require("got");
const ZosConnectService_1 = require("../../../api/service/ZosConnectService");
const ZosConnectBaseHandler_1 = require("../../ZosConnectBaseHandler");
class UpdateHandler extends ZosConnectBaseHandler_1.ZosConnectBaseHandler {
processCmd(commandParameters) {
return __awaiter(this, void 0, void 0, function* () {
const filePath = commandParameters.arguments.file;
let fileBuf;
try {
fileBuf = fs.readFileSync(filePath);
}
catch (error) {
commandParameters.response.console.error(`Unable to load SAR file (${error.message})`);
return;
}
try {
const service = yield ZosConnectService_1.ZosConnectService.update(this.session, commandParameters.arguments.serviceName, fileBuf);
commandParameters.response.console.log(`Successfully updated Service ${service.name}`);
}
catch (error) {
switch (error.constructor) {
case (got_1.HTTPError):
switch (error.response.statusCode) {
case 400:
commandParameters.response.console.error("Invalid SAR file specified");
break;
case 401:
case 403:
commandParameters.response.console.error("Security error, Service was not updated");
break;
case 404:
commandParameters.response.console.error(`Service ${commandParameters.arguments.serviceName} is not installed.`);
break;
case 409:
commandParameters.response.console.error("Unable to update Service, it conflicts with an existing Service");
break;
default:
commandParameters.response.console.error(error.response.statusMessage);
}
break;
default:
throw error;
}
}
});
}
}
exports.default = UpdateHandler;
//# sourceMappingURL=update.handler.js.map