@zowe/zos-files-for-zowe-sdk v7.24.0
z/OS Files Package
Contains APIs to interact with files and data sets on z/OS (using z/OSMF files REST endpoints).
API Examples
Create a dataset
import { IProfile, Session, Logger, LoggingConfigurer, ImperativeError,
CredentialManagerFactory } from "@zowe/imperative";
import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk";
import { getDefaultProfile } from "@zowe/core-for-zowe-sdk";
import { Create, ICreateDataSetOptions, IZosFilesResponse, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk";
(async () => {
//Initialize the Imperative Credential Manager Factory and Logger
Logger.initLogger(LoggingConfigurer.configureLogger('lib', {name: 'test'}));
// Uncommment the below line if the Secure Credential Store is in use
// await CredentialManagerFactory.initialize({service: "Zowe-Plugin"});
// Get the default z/OSMF profile and create a z/OSMF session with it
let defaultZosmfProfile: IProfile;
try {
defaultZosmfProfile = await getDefaultProfile("zosmf", true);
} catch (err) {
throw new ImperativeError({msg: "Failed to get a profile."});
}
// Create Options
const dataset: string = "ZOWEUSER.PUBLIC.NEW.DATASET";
const dataSetType = CreateDataSetTypeEnum.DATA_SET_CLASSIC;
const options: ICreateDataSetOptions = {
primary: 10,
secondary: 1,
alcunit: "TRK",
lrecl: 80
};
const session: Session = ZosmfSession.createBasicZosmfSession(defaultZosmfProfile);
let response: IZosFilesResponse;
response = await Create.dataSet(session, dataSetType, dataset, options);
console.log(response);
process.exit(0);
})().catch((err) => {
console.error(err);
process.exit(1);
});
Download all datasets in a partitioned dataset
import { IProfile, Session, Logger, LoggingConfigurer, ImperativeError,
CredentialManagerFactory } from "@zowe/imperative";
import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk";
import { getDefaultProfile } from "@zowe/core-for-zowe-sdk";
import { IDownloadOptions, Download, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk";
(async () => {
//Initialize the Imperative Credential Manager Factory and Logger
Logger.initLogger(LoggingConfigurer.configureLogger('lib', {name: 'test'}));
// Uncommment the below line if the Secure Credential Store is in use
// await CredentialManagerFactory.initialize({service: "Zowe-Plugin"});
// Get the default z/OSMF profile and create a z/OSMF session with it
let defaultZosmfProfile: IProfile;
try {
defaultZosmfProfile = await getDefaultProfile("zosmf", true);
} catch (err) {
throw new ImperativeError({msg: "Failed to get a profile."});
}
// Download Options
const dataset: string = "ZOWEUSER.PUBLIC.YOUR.DATASET.HERE";
const options: IDownloadOptions = {failFast: false};
const session: Session = ZosmfSession.createBasicZosmfSession(defaultZosmfProfile);
let response: IZosFilesResponse;
response = await Download.allMembers(session, dataset, options);
console.log(response);
process.exit(0);
})().catch((err) => {
console.error(err);
process.exit(1);
});
List datasets on z/OS
import { IProfile, Session, Logger, LoggingConfigurer, ImperativeError,
CredentialManagerFactory } from "@zowe/imperative";
import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk";
import { getDefaultProfile } from "@zowe/core-for-zowe-sdk";
import { List, IListOptions, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk";
(async () => {
//Initialize the Imperative Credential Manager Factory and Logger
Logger.initLogger(LoggingConfigurer.configureLogger('lib', {name: 'test'}));
// Uncommment the below line if the Secure Credential Store is in use
// await CredentialManagerFactory.initialize({service: "Zowe-Plugin"});
// Get the default z/OSMF profile and create a z/OSMF session with it
let defaultZosmfProfile: IProfile;
try {
defaultZosmfProfile = await getDefaultProfile("zosmf", true);
} catch (err) {
throw new ImperativeError({msg: "Failed to get a profile."});
}
// List Options
const dataset: string = "ZOWEUSER.*";
const options: IListOptions = {};
const session: Session = ZosmfSession.createBasicZosmfSession(defaultZosmfProfile);
let response: IZosFilesResponse;
response = await List.dataSet(session, dataset, options);
const objArray = response.apiResponse.items;
for (const obj of objArray) {
if (obj) {
console.log(obj.dsname.toString());
}
};
process.exit(0);
})().catch((err) => {
console.error(err);
process.exit(1);
});
Upload a file to Unix System Services
import { IProfile, Session, Logger, LoggingConfigurer, ImperativeError,
CredentialManagerFactory } from "@zowe/imperative";
import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk";
import { getDefaultProfile } from "@zowe/core-for-zowe-sdk";
import { Upload, IUploadOptions, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk";
(async () => {
//Initialize the Imperative Credential Manager Factory and Logger
Logger.initLogger(LoggingConfigurer.configureLogger('lib', {name: 'test'}));
// Uncommment the below line if the Secure Credential Store is in use
// await CredentialManagerFactory.initialize({service: "Zowe-Plugin"});
// Get the default z/OSMF profile and create a z/OSMF session with it
let defaultZosmfProfile: IProfile;
try {
defaultZosmfProfile = await getDefaultProfile("zosmf", true);
} catch (err) {
throw new ImperativeError({msg: "Failed to get a profile."});
}
// Upload Options
const localFile: string = "C:/Users/zoweuser/Documents/testFile.txt";
const remoteLocation: string = "/u/zoweuser/file.txt";
const options: IUploadOptions = {binary: true};
const session: Session = ZosmfSession.createBasicZosmfSession(defaultZosmfProfile);
let response: IZosFilesResponse;
response = await Upload.fileToUssFile(session, localFile, remoteLocation, options);
console.log(response);
process.exit(0);
})().catch((err) => {
console.error(err);
process.exit(1);
});
8 days ago
16 days ago
24 days ago
26 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
7 months ago
8 months ago
9 months ago
8 months ago
6 months ago
6 months ago
5 months ago
9 months ago
6 months ago
5 months ago
10 months ago
10 months ago
7 months ago
7 months ago
5 months ago
6 months ago
9 months ago
8 months ago
6 months ago
5 months ago
5 months ago
12 months ago
12 months ago
11 months ago
11 months ago
12 months ago
10 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago