opennms
Version:
Client API for the OpenNMS network monitoring platform
1 lines • 17.8 kB
JSON
{"remainingRequest":"/data/node_modules/babel-loader/lib/index.js!/data/node_modules/ts-loader/index.js!/data/src/api/OnmsServer.ts","dependencies":[{"path":"/data/src/api/OnmsServer.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/src/api/OnmsAuthConfig.ts","mtime":1553611371624},{"path":"/data/src/api/ServerMetadata.ts","mtime":1553611371628},{"path":"/data/src/api/ServerType.ts","mtime":1553611371628},{"path":"/data/src/internal/UUID.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}],"contextDependencies":[],"result":["\"use strict\";\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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/** @hidden */\n// tslint:disable-next-line\nvar URI = require('urijs');\nvar OnmsAuthConfig_1 = require(\"../api/OnmsAuthConfig\");\nvar ServerType_1 = require(\"./ServerType\");\nvar UUID_1 = require(\"../internal/UUID\");\n/**\n * Represents a remote OpenNMS server.\n * @module OnmsServer\n */\n\nvar OnmsServer = function () {\n /**\n * Construct a new OnmsServer object representing a remote server.\n * @example\n * <caption>provide a pre-existing [[OnmsAuthConfig]] for auth</caption>\n * ```javascript\n * const server = new OnmsServer('Test', 'https://myserver/opennms/', auth);\n * ```\n * @example\n * <caption>provide a username and password for auth</caption>\n * ```javascript\n * const server = new OnmsServer('Test', 'https://myserver/opennms/', 'admin', 'admin');\n * ```\n * @constructor\n * @param name - A name for the server suitable for display.\n * @param url - The URL to the server.\n * @param auth - An [[OnmsAuthConfig]], or the username to authorize as.\n * @param password - The password to authorize with if a username was\n * supplied to the `auth` parameter.\n */\n function OnmsServer(name, url, auth, password) {\n _classCallCheck(this, OnmsServer);\n\n this.id = UUID_1.UUID.generate();\n this.name = name;\n this.url = url;\n if (auth instanceof OnmsAuthConfig_1.OnmsAuthConfig) {\n this.auth = auth;\n } else {\n this.auth = new OnmsAuthConfig_1.OnmsAuthConfig(auth, password);\n }\n }\n /**\n * Given a relative URL fragment, construct a URL for that fragment on the server.\n * @param forFragment - The URL fragment to append to the server URL.\n * @parm withQuery - Query parameters to be appended to the URL.\n * @returns A complete URL.\n */\n\n\n _createClass(OnmsServer, [{\n key: \"resolveURL\",\n value: function resolveURL(forFragment, withQuery) {\n if (!this.url) {\n return undefined;\n }\n if (forFragment === undefined) {\n return this.url;\n }\n var uri = URI(this.url);\n if (forFragment.indexOf('/') === 0 || forFragment.indexOf('http') === 0) {\n uri = URI(forFragment);\n } else {\n uri = uri.segment(forFragment);\n }\n if (withQuery !== undefined) {\n uri = uri.addQuery(withQuery);\n }\n return uri.toString();\n }\n /**\n * Create a new server object from this existing one.\n */\n\n }, {\n key: \"clone\",\n value: function clone() {\n var auth = this.auth ? this.auth.clone() : undefined;\n var ret = new OnmsServer(this.name, this.url, auth);\n ret.metadata = this.metadata ? this.metadata.clone() : undefined;\n return ret;\n }\n /**\n * Get the hostname portion of the URL associated with this server.\n */\n\n }, {\n key: \"toString\",\n\n /** A string representation of this server suitable for display. */\n value: function toString() {\n if (this.metadata) {\n return 'OpenNMS ' + (this.metadata.type === ServerType_1.ServerTypes.MERIDIAN ? 'Meridian' : 'Horizon') + ' ' + this.metadata.version.displayVersion + ' at ' + (this.host || this.url);\n } else {\n return 'OpenNMS at ' + (this.host || this.url);\n }\n }\n }, {\n key: \"host\",\n get: function get() {\n if (!this.url) {\n return undefined;\n }\n return URI(this.url).hostname();\n }\n }]);\n\n return OnmsServer;\n}();\n\nexports.OnmsServer = OnmsServer;",{"version":3,"file":"/data/src/api/OnmsServer.ts","sourceRoot":"","sources":["/data/src/api/OnmsServer.ts"],"names":[],"mappings":";;;;;;;AAAA,AAAc;AACd,AAA2B;AAC3B,IAAM,AAAG,MAAG,AAAO,QAAC,AAAO,AAAC,AAAC;AAE7B,+BAAqD;AAErD,2BAAyC;AACzC,qBAAsC;AAEtC,AAGG,AACH;;;;;;AAgBE,AAkBG;;;;;;;;;;;;;;;;;;;AACH,wBAAY,AAAa,MAAE,AAAY,KAAE,AAA8B,MAAE,AAAiB;;;AACxF,AAAI,aAAC,AAAE,KAAG,OAAI,KAAC,AAAQ,AAAE,AAAC;AAC1B,AAAI,aAAC,AAAI,OAAG,AAAI,AAAC;AACjB,AAAI,aAAC,AAAG,MAAG,AAAG,AAAC;AACf,AAAE,AAAC,YAAC,AAAI,gBAAY,iBAAc,AAAC,gBAAC,AAAC;AACnC,AAAI,iBAAC,AAAI,OAAG,AAAI,AAAC,AACnB;AAAC,AAAC,AAAI,eAAC,AAAC;AACN,AAAI,iBAAC,AAAI,OAAG,IAAI,iBAAc,eAAC,AAAI,MAAE,AAAQ,AAAC,AAAC,AACjD;AAAC,AACH;AAAC;AAED,AAKG,AACI,AAAU;;;;;;;;;;mCAAC,AAAoB,aAAE,AAAe;AACrD,AAAE,AAAC,gBAAC,CAAC,AAAI,KAAC,AAAG,AAAC,KAAC,AAAC;AACd,AAAM,uBAAC,AAAS,AAAC,AACnB;AAAC;AACD,AAAE,AAAC,gBAAC,AAAW,gBAAK,AAAS,AAAC,WAAC,AAAC;AAC9B,AAAM,uBAAC,AAAI,KAAC,AAAG,AAAC,AAClB;AAAC;AACD,gBAAI,AAAG,MAAG,AAAG,IAAC,AAAI,KAAC,AAAG,AAAC,AAAC;AACxB,AAAE,AAAC,gBAAC,AAAW,YAAC,AAAO,QAAC,AAAG,AAAC,SAAK,AAAC,KAAI,AAAW,YAAC,AAAO,QA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AI,KAAC,AAAI,QAAI,AAAI,KAAC,AAAG,AAAC,AAAC,AACvC;AAAC,AAAC,AAAI,mBAAC,AAAC;AACN,AAAM,uBAAC,AAAa,AAAG,iBAAC,AAAI,KAAC,AAAI,QAAI,AAAI,KAAC,AAAG,AAAC,AAAC,AACjD;AAAC,AACH;AAAC,AACF;;;;AAjBG,AAAE,AAAC,gBAAC,CAAC,AAAI,KAAC,AAAG,AAAC,KAAC,AAAC;AACd,AAAM,uBAAC,AAAS,AAAC,AACnB;AAAC;AACD,AAAM,mBAAC,AAAG,IAAC,AAAI,KAAC,AAAG,AAAC,KAAC,AAAQ,AAAE,AAAC,AAClC;AAAC;;;;;;AAzFH,qBAsGC","sourcesContent":["/** @hidden */\n// tslint:disable-next-line\nconst URI = require('urijs');\n\nimport {OnmsAuthConfig} from '../api/OnmsAuthConfig';\nimport {ServerMetadata} from './ServerMetadata';\nimport {ServerTypes} from './ServerType';\nimport {UUID} from '../internal/UUID';\n\n/**\n * Represents a remote OpenNMS server.\n * @module OnmsServer\n */\nexport class OnmsServer {\n /** A unique identifier for this server. */\n public id: string;\n\n /** An optional name associated with this server. */\n public name?: string;\n\n /** The base URL to the server. */\n public url: string;\n\n /** The authorization configuration associated with the server. */\n public auth: OnmsAuthConfig;\n\n /** The capabilities of the server */\n public metadata: ServerMetadata;\n\n /**\n * Construct a new OnmsServer object representing a remote server.\n * @example\n * <caption>provide a pre-existing [[OnmsAuthConfig]] for auth</caption>\n * ```javascript\n * const server = new OnmsServer('Test', 'https://myserver/opennms/', auth);\n * ```\n * @example\n * <caption>provide a username and password for auth</caption>\n * ```javascript\n * const server = new OnmsServer('Test', 'https://myserver/opennms/', 'admin', 'admin');\n * ```\n * @constructor\n * @param name - A name for the server suitable for display.\n * @param url - The URL to the server.\n * @param auth - An [[OnmsAuthConfig]], or the username to authorize as.\n * @param password - The password to authorize with if a username was\n * supplied to the `auth` parameter.\n */\n constructor(name?: string, url?: string, auth?: OnmsAuthConfig | string, password?: string) {\n this.id = UUID.generate();\n this.name = name;\n this.url = url;\n if (auth instanceof OnmsAuthConfig) {\n this.auth = auth;\n } else {\n this.auth = new OnmsAuthConfig(auth, password);\n }\n }\n\n /**\n * Given a relative URL fragment, construct a URL for that fragment on the server.\n * @param forFragment - The URL fragment to append to the server URL.\n * @parm withQuery - Query parameters to be appended to the URL.\n * @returns A complete URL.\n */\n public resolveURL(forFragment?: string, withQuery?: any) {\n if (!this.url) {\n return undefined;\n }\n if (forFragment === undefined) {\n return this.url;\n }\n let uri = URI(this.url);\n if (forFragment.indexOf('/') === 0 || forFragment.indexOf('http') === 0) {\n uri = URI(forFragment);\n } else {\n uri = uri.segment(forFragment);\n }\n if (withQuery !== undefined) {\n uri = uri.addQuery(withQuery);\n }\n return uri.toString();\n }\n\n /**\n * Create a new server object from this existing one.\n */\n public clone() {\n const auth = (this.auth ? this.auth.clone() : undefined);\n const ret = new OnmsServer(this.name, this.url, auth);\n ret.metadata = (this.metadata ? this.metadata.clone() : undefined);\n return ret;\n }\n\n /**\n * Get the hostname portion of the URL associated with this server.\n */\n get host() {\n if (!this.url) {\n return undefined;\n }\n return URI(this.url).hostname();\n }\n\n /** A string representation of this server suitable for display. */\n public toString() {\n if (this.metadata) {\n return 'OpenNMS '\n + (this.metadata.type === ServerTypes.MERIDIAN ? 'Meridian' : 'Horizon')\n + ' ' + this.metadata.version.displayVersion\n + ' at ' + (this.host || this.url);\n } else {\n return 'OpenNMS at ' + (this.host || this.url);\n }\n }\n}\n"]}]}