Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @zowe/zos-files-for-zowe-sdk

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

Index

Type aliases

CLIENT_PROPERTY

CLIENT_PROPERTY: "requestSuccess" | "requestFailure" | "data" | "dataString" | "response" | "session" | "log"

String type definition for properties of abstractRestClient that have a getter set. This can be safely used in a getter call as a variable for the abstractRestClient object.

export

IMountFsMode

IMountFsMode: "rdonly" | "rdwr"

Type for the mode option of the mount file-system API.

export

ZosmfMigratedRecallOptions

ZosmfMigratedRecallOptions: "wait" | "nowait" | "error"

z/OSMF options for recall of migrated data sets. See the z/OSMF REST API publication for complete details.

export

Object literals

Const CreateDefaults

CreateDefaults: object

Defaults to be used as options for the different types of data sets that can be created

DATA_SET

DATA_SET: object

Specifies all the defaults to create non-vsam data sets

BLANK

BLANK: {}

Specifies the defaults used by the Zos Files API to create a blank data set

Type declaration

BINARY

BINARY: object

Specifies the defaults used by the Zos Files API to create a data set used for binaries

alcunit

alcunit: string = "CYL"

blksize

blksize: number = 27998

dirblk

dirblk: number = 25

dsorg

dsorg: string = "PO"

lrecl

lrecl: number = 27998

primary

primary: number = 10

recfm

recfm: string = "U"

C

C: object

Specifies the defaults used by the Zos Files API to create a data set used for C code

alcunit

alcunit: string = "CYL"

blksize

blksize: number = 32760

dirblk

dirblk: number = 25

dsorg

dsorg: string = "PO"

lrecl

lrecl: number = 260

primary

primary: number = 1

recfm

recfm: string = "VB"

CLASSIC

CLASSIC: object

Specifies the defaults used by the Zos Files API to create a classic data set

alcunit

alcunit: string = "CYL"

blksize

blksize: number = 6160

dirblk

dirblk: number = 25

dsorg

dsorg: string = "PO"

lrecl

lrecl: number = 80

primary

primary: number = 1

recfm

recfm: string = "FB"

PARTITIONED

PARTITIONED: object

Specifies the defaults used by the Zos Files API to create a partitioned data set

alcunit

alcunit: string = "CYL"

blksize

blksize: number = 6160

dirblk

dirblk: number = 5

dsorg

dsorg: string = "PO"

lrecl

lrecl: number = 80

primary

primary: number = 1

recfm

recfm: string = "FB"

SEQUENTIAL

SEQUENTIAL: object

Specifies the defaults used by the Zos Files API to create a sequential data set

alcunit

alcunit: string = "CYL"

blksize

blksize: number = 6160

dsorg

dsorg: string = "PS"

lrecl

lrecl: number = 80

primary

primary: number = 1

recfm

recfm: string = "FB"

VSAM

VSAM: object

Specifies the defaults used by the Zos Files API to create a VSAM cluster

alcunit

alcunit: string = "KB"

dsorg

dsorg: string = "INDEXED"

primary

primary: number = 840

Const ZosFilesConstants

ZosFilesConstants: object

Constants to be used by the API

memberof

ZosFilesConstants

MAX_ALLOC_QUANTITY

MAX_ALLOC_QUANTITY: number = 16777215

Maximum value for primary and secondary allocation

MAX_AMS_BUFFER

MAX_AMS_BUFFER: number = 2

Maximum numbers of characters to allow for the continuation character on AMS statements

MAX_AMS_LINE

MAX_AMS_LINE: number = 255

Maximum length of an AMS statement

MAX_RETAIN_DAYS

MAX_RETAIN_DAYS: number = 93000

Maximum numbers of days for which to retain a dataset.

MIN_RETAIN_DAYS

MIN_RETAIN_DAYS: number = 0

Minimum numbers of days for which to retain a dataset.

RESOURCE

RESOURCE: string = "/zosmf/restfiles"

Specifies the z/OS data set and file REST interface

RES_AMS

RES_AMS: string = "/ams"

Indicator of an AMS request

RES_DS_FILES

RES_DS_FILES: string = "/ds"

Indicator of a data set request

RES_DS_LEVEL

RES_DS_LEVEL: string = "dslevel"

Indicator the query parameters used to qualify the request

RES_DS_MEMBERS

RES_DS_MEMBERS: string = "/member"

Indicator of a members request

memberof

ZosFilesConstants

RES_FSNAME

RES_FSNAME: string = "fsname"

Indicator of a ds file name

memberof

ZosFilesConstants

RES_MFS

RES_MFS: string = "/mfs"

Indicator of a z/OS mfs

RES_PATH

RES_PATH: string = "path"

Indicator of a USS File request

memberof

ZosFilesConstants

RES_USS_FILES

RES_USS_FILES: string = "/fs"

Indicator of a USS File request

RES_ZFS_FILES

RES_ZFS_FILES: string = "/mfs/zfs"

Indicator of a z/OS file system request

VSAM_ALCUNIT_CHOICES

VSAM_ALCUNIT_CHOICES: string[] = ["CYL", "TRK", "MB", "KB", "REC"]

The set of allocation unit choices for VSAM files

VSAM_DSORG_CHOICES

VSAM_DSORG_CHOICES: string[] = ["INDEXED", "IXD", "LINEAR", "LIN", "NONINDEXED", "NIXD", "NUMBERED", "NUMD", "ZFS"]

The set of dataset organization choices for VSAM files

Const ZosFilesMessages

ZosFilesMessages: object

Messages to be used as command responses for different scenarios

memberof

ZosFilesMessages

allDataSetsArchived

allDataSetsArchived: object

Message indicating that all data sets matching the provided patterns are archived.

message

message: string = "All data sets matching the selected pattern(s) were archived."

amsCommandExecutedSuccessfully

amsCommandExecutedSuccessfully: object

Message indicating that the AMS commands was executed successfully

message

message: string = "AMS command executed successfully."

attributeTitle

attributeTitle: object

Message indicating the attributes are used during dataset creation

message

message: string = "The following attributes are used during creation:"

attributesFileNotFound

attributesFileNotFound: object

Messaging indicating an attributes file was not found

message

message: string = "Attributes file {{file}} does not exist"

commonFor

commonFor: object

Message to be used when throwing an imperative error during dataset creation

message

message: string = "for"

commonWithValue

commonWithValue: object

Message to be used when throwing an imperative error during dataset creation

message

message: string = "with value"

dataSetCreatedSuccessfully

dataSetCreatedSuccessfully: object

Message indicating that the data set was created successfully

message

message: string = "Data set created successfully."

dataSetRenamedSuccessfully

dataSetRenamedSuccessfully: object

Message indicating that the data set has been renamed successfully.

message

message: string = "Data set renamed successfully."

dataSetUploadedSuccessfully

dataSetUploadedSuccessfully: object

Message indicating that file is uploaded to data set successfully

message

message: string = "Data set uploaded successfully."

datasetCopiedSuccessfully

datasetCopiedSuccessfully: object

Message indicating that the data set was copied successfully

message

message: string = "Data set copied successfully."

datasetDeletedSuccessfully

datasetDeletedSuccessfully: object

Message indicating that the data set was deleted successfully

message

message: string = "Data set deleted successfully."

datasetDeletionRequested

datasetDeletionRequested: object

Message indicating that the data set was deleted successfully.

message

message: string = "Data set deletion requested."

datasetDownloadedSuccessfully

datasetDownloadedSuccessfully: object

Message indicating that the data set was downloaded successfully

message

message: string = "Data set downloaded successfully.Destination: %s"

datasetMigrationRequested

datasetMigrationRequested: object

Message indicating that the data set was migrated successfully.

message

message: string = "Data set migration requested."

datasetRecallRequested

datasetRecallRequested: object

Message indicating that the data set was recalled successfully.

message

message: string = "Data set recall requested."

datasetsDownloadedSuccessfully

datasetsDownloadedSuccessfully: object

Message indicating that the data sets matching pattern was downloaded successfully

message

message: string = "Data sets matching pattern downloaded successfully.Destination: %s"

errorParsingAttributesFile

errorParsingAttributesFile: object

Message indicating an error parsing an attributes file

message

message: string = "Error parsing attributes file {{file}}: {{message}}"

errorReadingAttributesFile

errorReadingAttributesFile: object

Message indicating an error reading an attributes file

message

message: string = "Could not read attributes file {{file}}: {{message}}"

fsMountedSuccessfully

fsMountedSuccessfully: object

Message indicating that the file system was mounted successfully.

message

message: string = "File system mounted successfully."

fsUnmountedSuccessfully

fsUnmountedSuccessfully: object

Message indicating that the file system was unmounted successfully.

message

message: string = "File system unmounted successfully."

invalidAlcunitOption

invalidAlcunitOption: object

Message indicating invalid 'create' command 'alcunit' option

message

message: string = "Invalid zos-files create command 'alcunit' option: "

invalidAttributesSyntax

invalidAttributesSyntax: object

Messaging indicating invalid syntax in .zosattributes file

message

message: string = "Syntax error on line {{lineNumber}} - expected <pattern> <local encoding> <remote encoding>."

invalidDsntypeOption

invalidDsntypeOption: object

Message indicating invalid 'create' command 'dsntype' option

message

message: string = "Invalid zos-files create command 'dsntype' option: "

invalidDsorgOption

invalidDsorgOption: object

Message indicating invalid 'create' command 'dsorg' option

message

message: string = "Invalid zos-files create command 'dsorg' option: "

invalidFilesCreateOption

invalidFilesCreateOption: object

Message indicating an invalid 'create' command option

message

message: string = "Invalid zos-files create command option: "

invalidFilesMountOption

invalidFilesMountOption: object

Message indicating an invalid 'mount' command option

message

message: string = "Invalid zos-files mount command option: "

invalidMountModeOption

invalidMountModeOption: object

Message indicating invalid 'mount' command 'mode' option

message

message: string = "Invalid zos-files mount command 'mode' value: "

invalidPODsorgDirblkCombination

invalidPODsorgDirblkCombination: object

Message indicating that directory blocks cannot be zero if the data set organization is 'PO'

message

message: string = "'PO' data set organization (dsorg) specified and the directory blocks (dirblk) is zero."

invalidPSDsorgDirblkCombination

invalidPSDsorgDirblkCombination: object

Message indicating that directory blocks must be zero if the data set organization is 'PS'

message

message: string = "'PS' data set organization (dsorg) specified and the directory blocks (dirblk) is not zero."

invalidPermsOption

invalidPermsOption: object

Message indicating invalid 'create' command 'perms' option

message

message: string = "Invalid zos-files create command 'perms' option: "

invalidRecfmOption

invalidRecfmOption: object

Message indicating invalid 'create' command 'recfm' option

message

message: string = "Invalid zos-files create command 'recfm' option: "

longAmsStatement

longAmsStatement: object

Message indicating that the AMS commands was too long to be passed to z/OS MF

message

message: string = "Line %d is longer than %d characters (maximum allowed length)%s"

maximumAllocationQuantityExceeded

maximumAllocationQuantityExceeded: object

Message indicating the maximum allocation quantity has been exceeded

message

message: string = `Maximum allocation quantity of ${ZosFilesConstants.MAX_ALLOC_QUANTITY} exceeded`

memberDownloadFailed

memberDownloadFailed: object

Message indicating that the following members failed to properly download

message

message: string = "Failed to download the following members:"

missingDatasetLikeName

missingDatasetLikeName: object

Message indicating that the data set "like" name is required

message

message: string = "Specify the name of the data set to "allocate like" from."

missingDatasetName

missingDatasetName: object

Message indicating that the data set name is required

message

message: string = "Specify the data set name."

missingDatasetType

missingDatasetType: object

Message indicating that the data set type is required

message

message: string = "Specify the data set type."

missingFileSystemName

missingFileSystemName: object

Message indicating that the file system name is required

message

message: string = "Specify the file system name."

missingFilesCreateOptions

missingFilesCreateOptions: object

Message indicating the 'create' command options is null or undefined

message

message: string = "No zos-files create command options."

missingFilesMountOptions

missingFilesMountOptions: object

Message indicating the 'mount' command options is null or undefined

message

message: string = "No zos-files mount command options."

missingFsOption

missingFsOption: object

Message indicating that an expected file system option was not supplied.

message

message: string = "To mount a file system, the following option must be supplied: "

missingInputDir

missingInputDir: object

Message indicating that the input directory is required

message

message: string = "Specify the input directory path."

missingInputDirectory

missingInputDirectory: object

Message indicating that the input directory path is required

message

message: string = "Specify directory path, to upload."

missingInputFile

missingInputFile: object

Message indicating that the input file is required

message

message: string = "Specify the input file and, if needed, the path."

missingMountPoint

missingMountPoint: object

Message indicating that the mount point is required

message

message: string = "Specify the mount point."

missingPatterns

missingPatterns: object

Message indicating that patterns were not passed.

message

message: string = "No pattern to match data sets passed."

missingPayload

missingPayload: object

Message indicating that the payload is required

message

message: string = "Specify the payload."

missingPrimary

missingPrimary: object

Message indicating 'create' command 'primary' option is required

message

message: string = "Specify the primary allocation (primary) to create a data set."

missingRecordLength

missingRecordLength: object

Message indicating 'create' command 'lrecl' option is required

message

message: string = "Specify the record length (lrecl) to create a data set."

missingRequestType

missingRequestType: object

Message indicating that the request type is required

message

message: string = "Specify request type, file or directory."

missingStatements

missingStatements: object

Message indicating that the AMS statements is required

message

message: string = "Missing AMS statements to be submitted."

missingUSSDirectoryName

missingUSSDirectoryName: object

Message indicating that the USS directory name is required

message

message: string = "Specify the USS directory name."

missingUSSFileName

missingUSSFileName: object

Message indicating that the USS File name is required

message

message: string = "Specify the USS file name."

missingVsamOption

missingVsamOption: object

Message indicating that the an expected VSAM option was not supplied.

message

message: string = "To create a VSAM cluster, the following option must be supplied: "

missingZfsOption

missingZfsOption: object

Message indicating that an expected ZFS option was not supplied.

message

message: string = "To create a z/OS file system, the following option must be supplied: "

noDataSetsInList

noDataSetsInList: object

Message indicating that no data sets remain to be downloaded after the excluded ones were filtered out.

message

message: string = "No data sets left after excluded pattern(s) were filtered out."

noDataSetsMatchingPattern

noDataSetsMatchingPattern: object

Message indicating that no data sets remain to be downloaded after the excluded ones were filtered out.

message

message: string = "There are no data sets that match the provided pattern(s)."

noDataSetsMatchingPatternRemain

noDataSetsMatchingPatternRemain: object

Message indicating that no data sets remain to be downloaded after the excluded ones were filtered out.

message

message: string = "After filtering out the archived files and files that match the exclusion-parameters, no data sets matching" +" the supported organization type remain."

noMembersFound

noMembersFound: object

Message indicating that the no members were found

message

message: string = "No members found!"

nodeJsFsError

nodeJsFsError: object

Message indicating that a failure has happened in the NodeJS File System API

message

message: string = "Node.js File System API error"

onlyEmptyPartitionedDataSets

onlyEmptyPartitionedDataSets: object

Message indicating that only empty partitioned data sets match the provided patterns

message

message: string = "Only empty partitioned data sets match the provided patterns."

pathIsNotDirectory

pathIsNotDirectory: object

Message indicating that input path is not a directory

message

message: string = "%s is not a directory"

unsupportedDatasetType

unsupportedDatasetType: object

Message indicating that the data set type is unsupported

message

message: string = "Unsupported data set type."

unsupportedMaskingInDataSetName

unsupportedMaskingInDataSetName: object

message

message: string = "Unsupported masking character found in data set name."

uploadDirectoryToDatasetMember

uploadDirectoryToDatasetMember: object

Message indicating that attempt to upload a directory to a data set member

message

message: string = "Upload a directory to a data set member is not permitted"

uploadDirectoryToPhysicalSequentialDataSet

uploadDirectoryToPhysicalSequentialDataSet: object

Message indicating that attempt to upload a directory with multiple files to a physical sequential data set

message

message: string = "Upload a directory with multiple files to a physical sequential data set is not permitted"

ussCreatedSuccessfully

ussCreatedSuccessfully: object

Message indicating that the uss file or directory crated successfully.

message

message: string = "USS file or directory created successfully."

ussDirUploadedSuccessfully

ussDirUploadedSuccessfully: object

Message indicating that the uss directory was uploaded successfully

message

message: string = "Directory uploaded successfully."

ussFileDeletedSuccessfully

ussFileDeletedSuccessfully: object

Message indicating that the USS file or directory was deleted successfully

message

message: string = "USS File or directory deleted successfully."

ussFileDownloadedSuccessfully

ussFileDownloadedSuccessfully: object

Message indicating that the uss file was downloaded successfully

message

message: string = "USS file downloaded successfully.Destination: %s"

ussFileUploadedSuccessfully

ussFileUploadedSuccessfully: object

Message indicating that the uss file was uploaded successfully

message

message: string = "USS file uploaded successfully."

valueOutOfBounds

valueOutOfBounds: object

Message indicating that the an expected VSAM option was not supplied.

message

message: string = "The {{optionName}} value = '{{value}}' must be between {{minValue}} and {{maxValue}}."

zfsCreatedSuccessfully

zfsCreatedSuccessfully: object

Message indicating that the ZFS was created successfully

message

message: string = "z/OS file system created successfully."

zfsDeletedSuccessfully

zfsDeletedSuccessfully: object

Message indicating that the ZFS was deleted successfully

message

message: string = "z/OS file system deleted successfully."

Generated using TypeDoc