Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getClientWithMetadata() {
if (!this.clientWithMetadata) {
const self = this;
const http = self.client.http;
const client = Client.getMetadata(http.server, http, self.timeout)
.then(function(metadata) {
// Ensure the OpenNMS we are talking to is compatible
if (metadata.apiVersion() < 2) {
throw new Error("Unsupported Version");
}
const server = API.OnmsServer.newBuilder(http.server.url)
.setName(http.server.name)
.setAuth(http.server.auth)
.setMetadata(metadata)
.build();
http.server = server;
return self.client;
}).catch(function(e) {
// in case of error, reset the client, otherwise
// the datasource may never recover
self.clientWithMetadata = void 0;