7.24.0 • Published 8 days ago

@zowe/zos-files-for-zowe-sdk v7.24.0

Weekly downloads
610
License
EPL-2.0
Repository
github
Last release
8 days ago

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);
});
6.40.28

16 days ago

7.24.0

26 days ago

7.23.9

1 month ago

6.40.27

1 month ago

7.23.8

1 month ago

7.23.7

1 month ago

7.23.6

1 month ago

7.23.4

2 months ago

7.23.3

2 months ago

7.23.2

2 months ago

6.40.26

2 months ago

7.23.1

3 months ago

7.23.0

3 months ago

7.22.0

3 months ago

7.21.4

4 months ago

7.21.3

4 months ago

7.21.2

4 months ago

7.21.1

4 months ago

6.40.25

4 months ago

7.21.0

5 months ago

7.18.7

7 months ago

7.18.2

8 months ago

7.18.0

9 months ago

7.18.1

8 months ago

7.18.8

6 months ago

7.18.9

6 months ago

7.17.0

9 months ago

7.20.0

5 months ago

7.16.6

10 months ago

7.16.5

10 months ago

6.40.21

7 months ago

6.40.20

7 months ago

7.19.0

5 months ago

6.40.22

6 months ago

6.40.18

9 months ago

6.40.19

8 months ago

7.18.11

6 months ago

7.16.0

12 months ago

7.16.1

12 months ago

7.16.4

11 months ago

7.16.3

11 months ago

7.15.0

12 months ago

6.40.17

10 months ago

7.14.0

12 months ago

7.14.1

12 months ago

7.13.0

1 year ago

7.12.0

1 year ago

7.11.3

1 year ago

7.11.1

1 year ago

7.11.2

1 year ago

7.11.0

1 year ago

6.40.16

1 year ago

6.40.15

1 year ago

7.3.1

2 years ago

7.3.0

2 years ago

7.8.0

1 year ago

7.4.2

2 years ago

7.4.1

2 years ago

7.0.0

2 years ago

6.39.0

2 years ago

6.39.1

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

7.5.1

2 years ago

7.5.0

2 years ago

7.9.3

1 year ago

7.9.2

1 year ago

7.9.0

1 year ago

7.9.7

1 year ago

7.9.6

1 year ago

7.1.3

2 years ago

7.1.2

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

7.6.2

2 years ago

7.6.1

2 years ago

7.2.5

2 years ago

7.6.0

2 years ago

7.2.3

2 years ago

6.38.0

2 years ago

6.40.3

2 years ago

6.40.2

2 years ago

6.40.5

2 years ago

6.40.4

2 years ago

6.40.7

2 years ago

6.40.6

2 years ago

6.40.8

2 years ago

6.40.1

2 years ago

7.2.2

2 years ago

6.37.8

2 years ago

7.2.0

2 years ago

6.40.13

1 year ago

7.7.0

2 years ago

6.40.10

1 year ago

6.40.12

1 year ago

7.10.4

1 year ago

7.10.2

1 year ago

7.10.0

1 year ago

7.10.1

1 year ago

6.36.1

3 years ago

6.37.4

2 years ago

6.37.2

2 years ago

6.37.3

2 years ago

6.37.6

2 years ago

6.37.1

2 years ago

6.36.0

3 years ago

6.34.0

3 years ago

6.33.4

3 years ago

6.34.1

3 years ago

6.33.2

3 years ago

6.33.3

3 years ago

6.33.1

3 years ago

6.33.0

3 years ago

6.32.1

3 years ago

6.32.0

3 years ago

6.31.1

3 years ago

6.31.0

3 years ago

6.30.0

3 years ago

6.29.0

3 years ago

6.28.0

3 years ago

6.27.0

3 years ago

6.26.0

3 years ago

6.25.1

3 years ago

6.25.0

3 years ago

6.24.5

3 years ago

6.24.4

3 years ago

6.24.2

3 years ago

6.24.1

4 years ago