@zowe/zos-files-for-zowe-sdk
Version:
Zowe SDK to interact with files and data sets on z/OS
77 lines • 4.04 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.
*
*/
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.Get = void 0;
const imperative_1 = require("@zowe/imperative");
const ZosFiles_messages_1 = require("../../constants/ZosFiles.messages");
const Download_1 = require("../download/Download");
/**
* This class holds helper functions that are used to get the content of data sets or USS files through the z/OSMF APIs
* @export
* @class Get
*/
class Get {
/**
* Retrieve data sets content
*
* @param {AbstractSession} session - z/OSMF connection info
* @param {string} dataSetName - contains the data set name
* @param {IGetOptions} [options={}] - contains the options to be sent
*
* @returns {Promise<Buffer>} Promise that resolves to the content of the data set
*
* @throws {ImperativeError}
*/
static dataSet(session_1, dataSetName_1) {
return __awaiter(this, arguments, void 0, function* (session, dataSetName, options = {}) {
var _a;
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(dataSetName, ZosFiles_messages_1.ZosFilesMessages.missingDatasetName.message);
imperative_1.ImperativeExpect.toNotBeEqual(dataSetName, "", ZosFiles_messages_1.ZosFilesMessages.missingDatasetName.message);
const responseStream = new imperative_1.BufferBuilder();
yield Download_1.Download.dataSet(session, dataSetName, Object.assign(Object.assign({}, options), { stream: responseStream }));
return (_a = responseStream.read()) !== null && _a !== void 0 ? _a : Buffer.alloc(0);
});
}
/**
* Retrieve USS file content
*
* @param {AbstractSession} session - z/OSMF connection info
* @param {string} USSFileName - contains the data set name
* @param {IGetOptions} [options={}] - contains the options to be sent
*
* @returns {Promise<Buffer>} Promise that resolves to the content of the uss file
*
* @throws {ImperativeError}
*/
static USSFile(session_1, USSFileName_1) {
return __awaiter(this, arguments, void 0, function* (session, USSFileName, options = {}) {
var _a;
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(USSFileName, ZosFiles_messages_1.ZosFilesMessages.missingUSSFileName.message);
imperative_1.ImperativeExpect.toNotBeEqual(USSFileName, "", ZosFiles_messages_1.ZosFilesMessages.missingUSSFileName.message);
imperative_1.ImperativeExpect.toNotBeEqual(options.record, true, ZosFiles_messages_1.ZosFilesMessages.unsupportedDataType.message); // This should never exist for USS files
const responseStream = new imperative_1.BufferBuilder();
yield Download_1.Download.ussFile(session, USSFileName, Object.assign(Object.assign({}, options), { stream: responseStream }));
return (_a = responseStream.read()) !== null && _a !== void 0 ? _a : Buffer.alloc(0);
});
}
}
exports.Get = Get;
//# sourceMappingURL=Get.js.map