IBM/zos-node-accessor

Name: zos-node-accessor

Owner: International Business Machines

Description: z/OS Node Accessor - A Node module to help Node.JS developers interacting with z/OS easily.

Created: 2017-09-06 11:10:37.0

Updated: 2018-05-21 10:23:33.0

Pushed: 2018-05-24 15:34:36.0

Homepage:

Size: 28

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

z/OS Node Accessor

Build Status

A Node module to help Node.JS developers interacting with z/OS easily, taking advantage of z/OS FTP service. It's recommended to be deployed on z/OS, to avoid transferring user account/password in clear-text over network. IBM SDK for Node.js - z/OS Beta is available at https://developer.ibm.com/node/sdk/ztp/.

Installation & Test
install zos-node-accessor   # Put latest version in your package.json
test                        # You'll need the dev dependencies to launch tests
Features
Usage

This accessor leverages z/OS FTP server to interact with z/OS, it requires JESINTERFACELevel set to 2

Connection

Before connecting to a z/OS server, you need to initialize an instance using the constructor new zosAccessor(), then call the connect(config) method, where:

Parameter Return

A promise that resolves itself(the connection to z/OS), and rejects on any error.

Example
Client = require('zosAccessor');

c = new Client();
onnect to localhost:21 as hansome using password
nnect({user: 'myname', password:'mypassword'})
hen(function(connection) {
// here connection equals to outer c

atch(function(err) {
// handle error
;
MVS dataset or USS files
List

listDataset(dsnOrDir) - List MVS datasets or USS files

Parameter Return

A promise that resolves a list of

Example
ection.listDataset('HQL.*.JCL')
hen(function(list) {
for(var i=0; i<list.length; ++i) {
  var entry = list[i];
  console.log('name:', entry['Dsname'], 'dsorg', entry['Dsorg']);
}

atch(function(err) {
// handle error
;
s
ection.listDataset('/u/user1/')
hen(function(list) {
for(var i=0; i<list.length; ++i) {
  var entry = list[i];
  console.log(entry.name, entry.owner, entry.group, entry.size);
}

atch(function(err) {
// handle error
;
Upload MVS dataset or USS file

uploadDataset(input, destDataset, dataType) - Upload a local file to MVS dataset or USS file.

Parameter Return

A promise that resolves on success, rejects on error.

Example
fs = require('fs');
input = fs.readFileSync('/etc/hosts', 'utf8').replace(/\r?\n/g, '\r\n');
ection.uploadDataset(input, 'hosts')
hen(function() {
console.log('Success');

atch(function(err) {
// handle error
;
Read MVS dataset or USS file

getDataset(dsn, dataType, stream) - Get the contents of the MVS dataset or USS file.

Parameter Return

A promise that resolves content of the dataset or file in either Buffer or ReadableStream.

Example
ection.getDataset('HQL.AA.JCL', 'ascii')
hen(function(jclBuffer) {
console.log('JCL is:');
console.log(jclBuffer.toString());

atch(function(err) {
// handle error
;
Delete

delete(dsn) - Delete a dataset or USS file.

Parameter Return

A promise that resolves on success, rejects on error.

Example
ection.deleteDataset('HQL.AA.JCL')
hen(function() {
console.log('Deleted');

atch(function(err) {
// handle error
;
Rename

rename(oldDataset, newDataset) - Renames oldDataset to newDataset.

Parameter Return

A promise that resolves on success, rejects on error.

Example
ection.rename('HQL.AA.JCL', 'HQL.BB.JCL')
hen(function() {
console.log('Renamed');

atch(function(err) {
// handle error
;
JES jobs
List jobs

listJobs(jobName) - List JES jobs under a certain job name.

Parameter Return

A promise that resolves an array of jobs, each item in the array is a string separated by space, for JESINTERFACELEVEL=2, those fields are JOBNAME, JOBID, OWNER, STATUS, CLASS

Example
ection.listJobs('HIS*')
hen(function(jobList) {

atch(function(err) {
// handle error
;
Submit JCL

submitJCL(JCLText, cfg) - Submit raw JCL text to JES server, or submitting built-in helper JCLs

Parameter Return

A promise that resolves the submitted job id.

Example
fs = require('fs');

eadFile('./unpaxz.jcl', function(err, jclContent) {
nnection.submitJCL(jclContent)
.then(function(jobId) {
  console.log('Job id is', jobId);
})
.catch(function(err) {
  // handle error
});

ection.submitJCL('HRECALLW', {INPUT: 'AA.BB'})
hen(function(jobId) {
console.log('Job id is', jobId);

atch(function(err) {
// handle error
;
Query job status

queryJob(jobName, jobId) - Get job status identified by job name and job id.

Parameter Return

A promise that resolves status of the job, it is one of the following values:

Example
ection.queryJCL(jobName, jobId)
hen(function (status) {
  switch(status) {
      case connection.RC_SUCCESS:
          console.log('Job succeeded');
          break;
      case connection.RC_FAIL:
          console.log('Job failed');
          break;
      case connection.RC_ACTIVE:
          console.log('Job running');
          break;
      case connection.RC_NOT_FOUND:
          console.log('Job not found');
          break;
      default:
          console.log('Unknown status');
  }
;
Get JES spool files

getJobLog(jobName, jobId) - Get jes spool files identified by jobName and jobId.

Parameter Return

A promise that resolves spool files populated by the job.

Example
ection.getJobLog(jobName, jobId)
hen(function(jobLog) {
console.log('Job id is:');
console.log(jobLog);

atch(function(err) {
// handle error
;
License

Eclipse Public License (EPL)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.