/* eslint-disable max-classes-per-file */ /** @hidden */ // eslint-disable-next-line const URI = require('urijs'); import {OnmsAuthConfig} from '../api/OnmsAuthConfig'; import {ServerMetadata} from './ServerMetadata'; import {ServerTypes} from './ServerType'; import {MD5} from 'object-hash'; /** * A builder for [[OnmsServer]]. Create a new one with [[OnmsServer.newBuilder]]. * @category Rest */ /* eslint-disable , @typescript-eslint/naming-convention,no-underscore-dangle,id-denylist,id-match, */ export class OnmsServerBuilder { /** @hidden */ private _name?: string; /** @hidden */ private _url?: string; /** @hidden */ private _auth?: OnmsAuthConfig; /** @hidden */ private _metadata?: ServerMetadata; /** * Construct a new builder from an existing options object, if provided. */ public constructor(url?: string) { this._url = url; } /** Build the [[OnmsServer]] object. */ public build(): OnmsServer { return new OnmsServer(this); } /** * The display name of the server. * * If `undefined` is passed, the name will be unset. * @param name the server name */ public setName(name?: string) { this._name = name; return this; } /** * The URL of the server. * * If `undefined` is passed, the URL will be unset. * @param url the server's URL */ public setUrl(url?: string) { this._url = url; return this; } /** * The authentication config to use when connecting. * * If `undefined` is passed, the default authentication settings will be used. * @param auth the authentication config */ public setAuth(auth?: OnmsAuthConfig) { this._auth = auth; return this; } /** * The server metadata to associate with the server. * * If `undefined` is passed, no metadata will be used. * @param metadata the metadata */ public setMetadata(metadata?: ServerMetadata) { this._metadata = metadata; return this; } public get name() { return this._name; } public get url() { return this._url; } public get auth() { return this._auth; } public get metadata() { return this._metadata; } } /* eslint-enable , @typescript-eslint/naming-convention,no-underscore-dangle,id-denylist,id-match, */ /** * Represents a remote OpenNMS server. * @category Rest */ export class OnmsServer { /** * Create a new builder for an [[OnmsServer]] object. */ public static newBuilder(url?: string) { return new OnmsServerBuilder(url); } /** A unique identifier for this server. */ public readonly id: string; /** An optional name associated with this server. */ public readonly name?: string; /** The base URL to the server. */ public readonly url: string; /** The authorization configuration associated with the server. */ public readonly auth: OnmsAuthConfig | null; /** The capabilities of the server */ public readonly metadata: ServerMetadata | null; /** * Construct a new OnmsServer object representing a remote server. * @example *