opennms
Version:
Client API for the OpenNMS network monitoring platform
1 lines • 30.8 kB
JSON
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ts-loader/index.js!/data/node_modules/tslint-loader/index.js??ref--4-0!/data/src/Client.ts","dependencies":[{"path":"/data/src/Client.ts","mtime":1553611371624},{"path":"/data/node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts","mtime":1553611387808},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/LogGroupControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/control/CategoryServiceControl.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesToExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/MessagesFromExtensionJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionMessageJSON.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/AbstractCategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/LoggerOptions.d.ts","mtime":1553611387932},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryDelegateLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/category/CategoryMessageBufferImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/Logger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactory.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryService.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/LoggerFactoryRuntimeSettings.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/AbstractLogger.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/ConsoleLoggerImpl.d.ts","mtime":1553611388000},{"path":"/data/node_modules/typescript-logging/dist/commonjs/log/standard/MessageBufferLoggerImpl.d.ts","mtime":1553611388004},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/DataStructures.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/JSONHelper.d.ts","mtime":1553611387936},{"path":"/data/node_modules/typescript-logging/dist/commonjs/utils/MessageUtils.d.ts","mtime":1553611387936},{"path":"/data/node_modules/moment/moment.d.ts","mtime":1553611386704},{"path":"/data/node_modules/axios/index.d.ts","mtime":1553611386356},{"path":"/data/typings/index.d.ts","mtime":1553611371628},{"path":"/data/node_modules/@types/fs-extra/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/node/inspector.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/minimatch/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/glob/node_modules/@types/minimatch/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/handlebars/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/highlight.js/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jest/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/jquery/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/lodash/index.d.ts","mtime":1553611386320},{"path":"/data/node_modules/@types/lodash/common/common.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/array.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/collection.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/date.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/function.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/lang.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/math.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/number.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/object.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/seq.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/string.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/lodash/common/util.d.ts","mtime":1553611386984},{"path":"/data/node_modules/@types/marked/index.d.ts","mtime":1553611386368},{"path":"/data/node_modules/@types/shelljs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/@types/urijs/index.d.ts","mtime":1553611386380},{"path":"/data/node_modules/typescript/lib/lib.es2015.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.core.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.collection.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.generator.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.promise.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.iterable.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.proxy.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.reflect.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","mtime":1553611387384},{"path":"/data/node_modules/typescript/lib/lib.es5.d.ts","mtime":1553611387388},{"path":"/data/node_modules/typescript/lib/lib.dom.d.ts","mtime":1553611387384},{"path":"/data/node_modules/axios/index.d.ts","mtime":1553611386356},{"path":"/data/src/api/Log.ts","mtime":1553611371624},{"path":"/data/node_modules/typescript-logging/dist/commonjs/typescript-logging.d.ts","mtime":1553611387808},{"path":"/data/src/api/IHasHTTP.ts","mtime":1553611371624},{"path":"/data/src/api/IOnmsHTTP.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsAuthConfig.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsHTTPOptions.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsError.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsResult.ts","mtime":1553611371624},{"path":"/data/src/api/OnmsVersion.ts","mtime":1553611371624},{"path":"/data/src/api/ServerType.ts","mtime":1553611371628},{"path":"/data/src/api/TicketerConfig.ts","mtime":1553611371628},{"path":"/data/src/api/OnmsServer.ts","mtime":1553611371624},{"path":"/data/src/api/ServerMetadata.ts","mtime":1553611371628},{"path":"/data/src/dao/AlarmDAO.ts","mtime":1553611371628},{"path":"/data/src/dao/EventDAO.ts","mtime":1553611371628},{"path":"/data/src/dao/FlowDAO.ts","mtime":1553611371628},{"path":"/data/src/dao/NodeDAO.ts","mtime":1553611371628},{"path":"/data/src/dao/SituationFeedbackDAO.ts","mtime":1553611371628},{"path":"/data/src/rest/AxiosHTTP.ts","mtime":1553611371628},{"path":"/data/.babelrc","mtime":1553611371556},{"path":"/data/node_modules/cache-loader/dist/cjs.js","mtime":1553611387012},{"path":"/data/node_modules/babel-loader/lib/index.js","mtime":1553611386992},{"path":"/data/node_modules/ts-loader/index.js","mtime":1553611386824},{"path":"/data/node_modules/tslint-loader/index.js","mtime":1553611386824}],"contextDependencies":[],"result":["\"use strict\";\n\nvar _regenerator = require(\"babel-runtime/regenerator\");\n\nvar _regenerator2 = _interopRequireDefault(_regenerator);\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : new P(function (resolve) {\n resolve(result.value);\n }).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Log_1 = require(\"./api/Log\");\nvar typescript_logging_1 = require(\"typescript-logging\");\nvar OnmsHTTPOptions_1 = require(\"./api/OnmsHTTPOptions\");\nvar OnmsError_1 = require(\"./api/OnmsError\");\nvar OnmsVersion_1 = require(\"./api/OnmsVersion\");\nvar ServerType_1 = require(\"./api/ServerType\");\nvar TicketerConfig_1 = require(\"./api/TicketerConfig\");\nvar OnmsServer_1 = require(\"./api/OnmsServer\");\nvar ServerMetadata_1 = require(\"./api/ServerMetadata\");\nvar AlarmDAO_1 = require(\"./dao/AlarmDAO\");\nvar EventDAO_1 = require(\"./dao/EventDAO\");\nvar FlowDAO_1 = require(\"./dao/FlowDAO\");\nvar NodeDAO_1 = require(\"./dao/NodeDAO\");\nvar SituationFeedbackDAO_1 = require(\"./dao/SituationFeedbackDAO\");\nvar AxiosHTTP_1 = require(\"./rest/AxiosHTTP\");\n/** @hidden */\nexports.cat = new typescript_logging_1.Category('client', Log_1.catRoot);\n/**\n * The OpenNMS client. This is the primary interface to OpenNMS servers.\n * @module Client\n */\n\nvar Client = function () {\n _createClass(Client, null, [{\n key: \"checkServer\",\n\n /**\n * Given an OnmsServer object, check that it can be connected to.\n *\n * @param server - the server to check\n * @param httpImpl - the [[IOnmsHTTP]] implementation to use\n * @param timeout - how long to wait before giving up when making ReST calls\n */\n value: function checkServer(server, httpImpl, timeout) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee() {\n var opts, infoUrl;\n return _regenerator2.default.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n opts = new OnmsHTTPOptions_1.OnmsHTTPOptions(timeout, server.auth, server);\n\n if (httpImpl) {\n _context.next = 5;\n break;\n }\n\n if (Client.defaultHttp) {\n _context.next = 4;\n break;\n }\n\n throw new OnmsError_1.OnmsError('No HTTP implementation is configured!');\n\n case 4:\n httpImpl = Client.defaultHttp;\n\n case 5:\n opts.headers.accept = 'text/plain';\n infoUrl = server.resolveURL('rest/alarms/count');\n\n Log_1.log.debug('checkServer: checking URL: ' + infoUrl, exports.cat);\n _context.next = 10;\n return httpImpl.get(infoUrl, opts);\n\n case 10:\n return _context.abrupt(\"return\", true);\n\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this);\n }));\n }\n /**\n * Given an OnmsServer object, query what capabilities it has, and return the capabilities\n * associated with that server.\n *\n * @param server - the server to check\n * @param httpImpl - the [[IOnmsHTTP]] implementation to use\n * @param timeout - how long to wait before giving up when making ReST calls\n */\n\n }, {\n key: \"getMetadata\",\n value: function getMetadata(server, httpImpl, timeout) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee2() {\n var opts, infoUrl, response, version, metadata;\n return _regenerator2.default.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n opts = new OnmsHTTPOptions_1.OnmsHTTPOptions(timeout, server.auth, server);\n\n opts.headers.accept = 'application/json';\n\n if (httpImpl) {\n _context2.next = 6;\n break;\n }\n\n if (Client.defaultHttp) {\n _context2.next = 5;\n break;\n }\n\n throw new OnmsError_1.OnmsError('No default HTTP implementation is configured!');\n\n case 5:\n httpImpl = Client.defaultHttp;\n\n case 6:\n if (!timeout && httpImpl.options.timeout) {\n opts.timeout = httpImpl.options.timeout;\n }\n infoUrl = server.resolveURL('rest/info');\n\n Log_1.log.debug('getMetadata: checking URL: ' + infoUrl, exports.cat);\n _context2.next = 11;\n return httpImpl.get(infoUrl, opts);\n\n case 11:\n response = _context2.sent;\n version = new OnmsVersion_1.OnmsVersion(response.data.version, response.data.displayVersion);\n metadata = new ServerMetadata_1.ServerMetadata(version);\n\n if (response.data.packageName) {\n if (response.data.packageName.toLowerCase() === 'meridian') {\n metadata.type = ServerType_1.ServerTypes.MERIDIAN;\n }\n }\n if (metadata.ticketer()) {\n metadata.ticketerConfig = new TicketerConfig_1.TicketerConfig();\n metadata.ticketerConfig.enabled = false;\n if (response.data.ticketerConfig) {\n metadata.ticketerConfig.plugin = response.data.ticketerConfig.plugin;\n metadata.ticketerConfig.enabled = response.data.ticketerConfig.enabled === true;\n }\n }\n return _context2.abrupt(\"return\", metadata);\n\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n }\n /**\n * Construct a new OpenNMS client.\n * @constructor\n * @param httpImpl - The OnmsHTTP implementation to use. Normally\n * this will automatically choose the best implementation\n * based on the environment.\n */\n\n }]);\n\n function Client(httpImpl) {\n _classCallCheck(this, Client);\n\n if (httpImpl) {\n Client.defaultHttp = httpImpl;\n } else {\n Client.defaultHttp = new AxiosHTTP_1.AxiosHTTP();\n }\n this.http = Client.defaultHttp;\n }\n /**\n * Connect to an OpenNMS server, check what capabilities it has, and return an [[OnmsServer]]\n * for that connection.\n */\n\n\n _createClass(Client, [{\n key: \"connect\",\n value: function connect(name, url, username, password, timeout) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator2.default.mark(function _callee3() {\n var self, server;\n return _regenerator2.default.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n self = this;\n server = new OnmsServer_1.OnmsServer(name, url, username, password);\n _context3.next = 4;\n return Client.checkServer(server, undefined, timeout);\n\n case 4:\n _context3.next = 6;\n return Client.getMetadata(server, undefined, timeout);\n\n case 6:\n server.metadata = _context3.sent;\n\n if (!self.http) {\n self.http = Client.defaultHttp;\n }\n if (!self.http.server) {\n self.http.server = server;\n }\n self.server = server;\n return _context3.abrupt(\"return\", self);\n\n case 11:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this);\n }));\n }\n /** Get an alarm DAO for querying alarms. */\n\n }, {\n key: \"alarms\",\n value: function alarms() {\n return new AlarmDAO_1.AlarmDAO(this);\n }\n /** Get an event DAO for querying events. */\n\n }, {\n key: \"events\",\n value: function events() {\n return new EventDAO_1.EventDAO(this);\n }\n /** Get a node DAO for querying nodes. */\n\n }, {\n key: \"nodes\",\n value: function nodes() {\n return new NodeDAO_1.NodeDAO(this);\n }\n /** Get a flow DAO for querying flows. */\n\n }, {\n key: \"flows\",\n value: function flows() {\n return new FlowDAO_1.FlowDAO(this);\n }\n /** Get a situationFeedback DAO for submitting and querying correlation feedback. */\n\n }, {\n key: \"situationfeedback\",\n value: function situationfeedback() {\n return new SituationFeedbackDAO_1.SituationFeedbackDAO(this);\n }\n }]);\n\n return Client;\n}();\n\nexports.Client = Client;",{"version":3,"file":"/data/src/Client.ts","sourceRoot":"","sources":["/data/node_modules/tslint-loader/index.js??ref--4-0!/data/src/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,oBAAuC;AACvC,mCAA4C;AAM5C,gCAAsD;AACtD,0BAA0C;AAE1C,4BAA8C;AAC9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B,AAAE,AAAC,oCAAC,CAAC,AAAI,KAAC,AAAI,AAAC,MAAC,AAAC;AACf,AAAI,yCAAC,AAAI,OAAG,AAAM,OAAC,AAAW,AAAC,AACjC;AAAC;AACD,AAAE,AAAC,oCAAC,CAAC,AAAI,KAAC,AAAI,KAAC,AAAM,AAAC,QAAC,AAAC;AACtB,AAAI,yCAAC,AAAI,KAAC,AAAM,SAAG,AAAM,AAAC,AAC5B;AAAC;AACD,AAAI,qCAAC,AAAM,SAAG,AAAM,AAAC,AAErB,AAAM;kEAAC,AAAI,AAAC,AACd,AAAC;;;;;;;;;AAAA;AAED,AAA4C,AACrC,AAAM;;;;;AACX,AAAM,mBAAC,IAAI,WAAQ,SAAC,AAAI,AAAC,AAAC,AAC5B;AAAC;AAED,AAA4C,AACrC,AAAM;;;;;AACX,AAAM,mBAAC,IAAI,WAAQ,SAAC,AAAI,AAAC,AAAC,AAC5B;AAAC;AAED,AAAyC,AAClC,AAAK;;;;;AACV,AAAM,mBAAC,IAAI,UAAO,QAAC,AAAI,AAAC,AAAC,AAC3B;AAAC;AAED,AAAyC,AAClC,AAAK;;;;;AACV,AAAM,mBAAC,IAAI,UAAO,QAAC,AAAI,AAAC,AAAC,AAC3B;AAAC;AAED,AAAoF,AAC7E,AAAiB;;;;;AACtB,AAAM,mBAAC,IAAI,uBAAoB,qBAAC,AAAI,AAAC,AAAC,AACxC;AAAC,AACF;;;;;;AA3ID,iBA2IC","sourcesContent":["import * as axios from 'axios';\n\nimport {log, catRoot} from './api/Log';\nimport {Category} from 'typescript-logging';\n\nimport {IHasHTTP} from './api/IHasHTTP';\nimport {IOnmsHTTP} from './api/IOnmsHTTP';\n\nimport {OnmsAuthConfig} from './api/OnmsAuthConfig';\nimport {OnmsHTTPOptions} from './api/OnmsHTTPOptions';\nimport {OnmsError} from './api/OnmsError';\nimport {OnmsResult} from './api/OnmsResult';\nimport {OnmsVersion} from './api/OnmsVersion';\nimport {ServerType, ServerTypes} from './api/ServerType';\nimport {TicketerConfig} from './api/TicketerConfig';\n\nimport {OnmsServer} from './api/OnmsServer';\nimport {ServerMetadata} from './api/ServerMetadata';\n\nimport {AlarmDAO} from './dao/AlarmDAO';\nimport {EventDAO} from './dao/EventDAO';\nimport {FlowDAO} from './dao/FlowDAO';\nimport {NodeDAO} from './dao/NodeDAO';\nimport {SituationFeedbackDAO} from './dao/SituationFeedbackDAO';\n\nimport {AxiosHTTP} from './rest/AxiosHTTP';\n\n/** @hidden */\nexport const cat = new Category('client', catRoot);\n\n/**\n * The OpenNMS client. This is the primary interface to OpenNMS servers.\n * @module Client\n */\nexport class Client implements IHasHTTP {\n /**\n * Given an OnmsServer object, check that it can be connected to.\n *\n * @param server - the server to check\n * @param httpImpl - the [[IOnmsHTTP]] implementation to use\n * @param timeout - how long to wait before giving up when making ReST calls\n */\n public static async checkServer(server: OnmsServer, httpImpl?: IOnmsHTTP, timeout?: number): Promise<boolean> {\n const opts = new OnmsHTTPOptions(timeout, server.auth, server);\n if (!httpImpl) {\n if (!Client.defaultHttp) {\n throw new OnmsError('No HTTP implementation is configured!');\n }\n httpImpl = Client.defaultHttp;\n }\n opts.headers.accept = 'text/plain';\n\n const infoUrl = server.resolveURL('rest/alarms/count');\n log.debug('checkServer: checking URL: ' + infoUrl, cat);\n await httpImpl.get(infoUrl, opts);\n return true;\n }\n\n /**\n * Given an OnmsServer object, query what capabilities it has, and return the capabilities\n * associated with that server.\n *\n * @param server - the server to check\n * @param httpImpl - the [[IOnmsHTTP]] implementation to use\n * @param timeout - how long to wait before giving up when making ReST calls\n */\n public static async getMetadata(server: OnmsServer, httpImpl?: IOnmsHTTP, timeout?: number):\n Promise<ServerMetadata> {\n const opts = new OnmsHTTPOptions(timeout, server.auth, server);\n opts.headers.accept = 'application/json';\n if (!httpImpl) {\n if (!Client.defaultHttp) {\n throw new OnmsError('No default HTTP implementation is configured!');\n }\n httpImpl = Client.defaultHttp;\n }\n if (!timeout && httpImpl.options.timeout) {\n opts.timeout = httpImpl.options.timeout;\n }\n\n const infoUrl = server.resolveURL('rest/info');\n log.debug('getMetadata: checking URL: ' + infoUrl, cat);\n\n const response = await httpImpl.get(infoUrl, opts);\n const version = new OnmsVersion(response.data.version, response.data.displayVersion);\n const metadata = new ServerMetadata(version);\n if (response.data.packageName) {\n if (response.data.packageName.toLowerCase() === 'meridian') {\n metadata.type = ServerTypes.MERIDIAN;\n }\n }\n if (metadata.ticketer()) {\n metadata.ticketerConfig = new TicketerConfig();\n metadata.ticketerConfig.enabled = false;\n if (response.data.ticketerConfig) {\n metadata.ticketerConfig.plugin = response.data.ticketerConfig.plugin;\n metadata.ticketerConfig.enabled = response.data.ticketerConfig.enabled === true;\n }\n }\n return metadata;\n }\n\n /** The default OnmsHTTP implementation to be used when making requests */\n private static defaultHttp: IOnmsHTTP;\n\n /** the OnmsHTTP implementation that will be used when making requests */\n public http: IOnmsHTTP;\n\n /** The remote server to connect to */\n public server: OnmsServer;\n\n /**\n * Construct a new OpenNMS client.\n * @constructor\n * @param httpImpl - The OnmsHTTP implementation to use. Normally\n * this will automatically choose the best implementation\n * based on the environment.\n */\n constructor(httpImpl?: IOnmsHTTP) {\n if (httpImpl) {\n Client.defaultHttp = httpImpl;\n } else {\n Client.defaultHttp = new AxiosHTTP();\n }\n this.http = Client.defaultHttp;\n }\n\n /**\n * Connect to an OpenNMS server, check what capabilities it has, and return an [[OnmsServer]]\n * for that connection.\n */\n public async connect(name: string, url: string, username: string, password: string, timeout?: number) {\n const self = this;\n const server = new OnmsServer(name, url, username, password);\n\n await Client.checkServer(server, undefined, timeout);\n server.metadata = await Client.getMetadata(server, undefined, timeout);\n\n if (!self.http) {\n self.http = Client.defaultHttp;\n }\n if (!self.http.server) {\n self.http.server = server;\n }\n self.server = server;\n\n return self;\n }\n\n /** Get an alarm DAO for querying alarms. */\n public alarms() {\n return new AlarmDAO(this);\n }\n\n /** Get an event DAO for querying events. */\n public events() {\n return new EventDAO(this);\n }\n\n /** Get a node DAO for querying nodes. */\n public nodes() {\n return new NodeDAO(this);\n }\n\n /** Get a flow DAO for querying flows. */\n public flows() {\n return new FlowDAO(this);\n }\n\n /** Get a situationFeedback DAO for submitting and querying correlation feedback. */\n public situationfeedback() {\n return new SituationFeedbackDAO(this);\n }\n}\n"]}]}