A node.js module to interact with the Kyndryl ChatOps Knight API.
npm install chatops-knight-jsThis module provides a set of functions to help JavaScript Developers working with Kyndryl ChatOps Knight to authenticate and access API endpoints using JavaScript _promises_.
* Node JS
* Minimum: v12.x
* Recommended: v14.x
* npm
* Tested on: v8.3.x
* Kyndryl ChatOps Knight
* Recommended: v20.20
Note: Depending on your Windows setup windows-build-tools may need to be installed first. Also, for MacOS users, you should have xcode-select or entire Xcode App installed.
npm install chatops-knight-js --save
npm uninstall chatops-knight-js
``javascript`
{
// Indicates if the HTTP request to the knight server should use
// HTTPS (secure) or HTTP (non-secure) protocol
https: true,
// If https is true, then provide client certificate, client key and
// the root CA cert
// Client cert and key are optional now
cert: './client.crt',
key: './client.key',
cacert: './ck-prod-ca.crt',
// Indicate the server name for the ChatOps Knight API, all paths are relative to this one
baseUrl: 'https://chatops-prod-int.kyndryl.net',
// Indicate the internal path with API version
rootPath: 'api/v1',
// HTTP request timeout in milliseconds
timeout: 2000,
// If should use a proxy or not by the HTTP request
// Example:
// proxy: { host: proxy.ip, port: proxy.port }
proxy: false,
}
Production
`javascript
const knight = require('chatops-knight-js');
const knight = new Knight( {
https: true,
cert: './client.crt',
key: './client.key',
cacert: './ck-prod-ca.crt',
baseUrl: 'https://chatops-prod-int.kyndryl.net/',
rootPath: 'api/v1',
timeout: 2000,
proxy: false
});
`
Development
`javascript
const knight = require('chatops-knight-js');
const knight = new Knight( {
https: true,
cacert: './ck-dev-ca.crt',
baseUrl: 'https://chatops-dev-int.kyndryl.net/',
rootPath: 'api/v1',
timeout: 5000,
proxy: false
});
`
Check health status of the ChatOps Knight API server:
`javascript`
const status = await knight.healthCheck();
This package extends the error stack to differentiate if the exception occurred on the ChatOps Knight API layer or not. Also, adds a help message from the knight API docs.
`javascript`
try {
knight.function(...);
}
// An exception happened and it was thrown
catch(err) {
if(err.isKnightError) {
// This an error from ChatOps Knight API
// Check Knight hints on this error
console.log(err.knightHelpMessage);
// For some endpoints there are details on the error message
if (err.knightHelpMessage.details) {
console.error(err.knightHelpMessage.details);
}
}
else {
// Here is still the full Axios error, e.g. err.isAxiosError, err.response, err.request
// This allows handling of network/tls related issues
// Or just re-throw if you don't care
throw err;
}
}
The following ChatOps Knight API endpoints are currently covered.
| Endpoint | Function | HTTP Method | Dev Doc |
|:--------------|:--------------|:--------------|:--------------:|
| /ping | .healthCheck() | GET | Doc |/api/v1/initiateTicket
| | .initiateTicket(@params) | POST | Doc |/api/v1/updateTicket
| | .updateTicket(@params) | POST | Doc |/api/v1/sendDirectMessageToUser
| | .sendMessageToUser(@params) | POST | Doc |/api/v2/postMessage
| | .postMessage(@param) | POST | Doc |
| | | | |
Follow the detailed instructions from this doc.
* ChatOps Knight Production Internal API documentation
* ChatOps Knight Development Internal API documentation
Kyndryl ChatOps Knight (ChatOps Fabric) software is licensed under a commercial license to its customers.