2.0.0 • Published 6 years ago

zosconnect-node v2.0.0

Weekly downloads
2,438
License
Apache-2.0
Repository
github
Last release
6 years ago

Build status codecov.io Dependencies Module LTS Adopted'

Table of Contents

Node zosconnect

A wrapper service for z/OS® Connect EE, enabling node applications to discover and access zSystems resources that are service enabled by z/OS® Connect. Version 2 of this module pre-reqs z/OS Connect EE V3.0.8 or later.

Services and APIs are identified by name that is unique within the scope of the target z/OS® Connect instance (or cluster). The node application uses pre-existing knowledge of the service or API name, or discovers it dynamically by retrieving a list of available services or APIs. The z/OS® Connect node wrapper provides access to JSON request and response schemas for the specific z/OS® Connect service and the Swagger document for APIs, enabling the node application to invoke that service and process the response.

Installing

npm install zosconnect-node

Usage

Connecting to z/OS Connect

var ZosConnect = require('zosconnect-node');
var options = {
  uri:'http://mainframe:8080'
}
var zosconnect = new ZosConnect(options);

The options object matches exactly the options described by the request/request module. The uri or url parameter must be specified.

HTTPs Support

Create the options object with locations for the CA certificate file and optionally the client certificate and client private key (if using client authentication). If the strictSSL option is set to false then invalid SSL certificates can be used which may be of use in development environments.

var fs = require('fs');
var path = require('path');
var caFile = path.resolve(__dirname, 'ca.pem');
var certFile = path.resolve(__dirname, 'cert.pem');
var keyFile = path.resolve(__dirname, 'key.pem');
var options = {
  uri:'https://mainframe:9443',
  ca: fs.readFileSync(caFile),
  cert: fs.readFileSync(certFile),
  key: fs.readFileSync(keyFile),
  passphrase: 'passw0rd',
  strictSSL: true
}
Basic Authentication

Add the authentication credentials to the options object.

var options = {
  uri: 'http://mainframe:9080',
  auth: {
    user: 'userId',
    pass: 'password'
  }
}

APIs

Retrieve a list of APIs
zosconnect.getApis().then(console.log);
Get an API
zosconnect.getApi('healthApi').then(console.log);
Create an API
zosconnect.createApi(fs.readFileSync('api.aar')).then(console.log);
Call an API
zosconnect.getApi('healthApi').then((api) => {
  api.invoke('patient/12345', 'GET', null).then((response) => {
    if(response.statusCode != 200) {
      console.log('Invoke failed with respCode = ' + response.statusCode);
    } else {
      console.log(response.body);
    }
  }).catch(console.log);
});
Get the Swagger document for an API
zosconnect.getApi('healthApi').then((api) => {
  api.getApiDoc('swagger').then(console.log);
});
Start or Stop an API
zosconnect.getApi('healthApi', function(error, api){
  api.stop().catch(console.log);
  api.start().catch(console.log);
})
Update an API
zosconnect.getApi('healthApi').then((api) => {
  api.update(fs.readFileSync('healthApi.aar')).catch(console.log);
});
Delete an API
zosconnect.getApi('healthApi').then((api) => {
  api.delete().catch(console.log);
})

Services

Retrieve a list of services
zosconnect.getServices().then(console.log);
Create a Service
zosconnect.createService(fs.readFileSync('dateTimeService.sar')).then(console.log);
Get a service
zosconnect.getService('dateTimeService').then(console.log);
//normally this would then go on and work with the service
Invoke a service
zosconnect.getService('dateTimeService').then((service) => {
  service.invoke({input:'data'}).then((response) => {
    if(response.statusCode != 200) {
      console.log('Invoke failed with respCode = ' + response.statusCode);
    } else {
      console.log(response.body);
    }
  }).catch(console.log);
});
Get the request schema
zosconnect.getService('dateTimeService').then((service) => {
  service.getRequestSchema().then(console.log).catch(console.log);
});
Get the response schema
zosconnect.getService('dateTimeService').then((service) => {
  service.getResponseSchema().then(console.log).catch(console.log);;
});
Update a Service
zosconnect.getService('dateTimeService').then((service) => {
  service.update(fs.readFileSync('dateTimeService.sar')).catch(console.log);
});
Delete a Service
zosconnect.getService('dateTimeService').then((service) => {
  service.delete().catch(console.log);
})

Module Long Term Support Policy

This module adopts the Module Long Term Support (LTS) policy, with the following End Of Life (EOL) dates:

Module VersionRelease DateMinimum EOLEOL WithStatus
2.x.xJul 2018Dec 2019Current
1.x.xJul 2017Dec 2019Node 8LTS

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago

0.2.0

8 years ago