pterowrap
Version:
A node.js wrapper for Pterodactyl API
42 lines (41 loc) • 1.53 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Database {
constructor(_client, data, _parentServer) {
this._client = _client;
this._parentServer = _parentServer;
const attributes = data.attributes;
this.id = attributes.id;
this.host = attributes.host;
this.name = attributes.name;
this.username = attributes.username;
this.connections_from = attributes.connections_from;
this.max_connections = attributes.max_connections;
this.relationships = attributes.relationships ? attributes.relationships : {};
this.raw = attributes;
}
rotatePassword() {
return new Promise(async (resolve, reject) => {
try {
resolve(new Database(this._client, (await this._client.call({
endpoint: `servers/${this._parentServer.identifier}/databases/${this.id}/rotate-password`,
method: "POST",
})).data, this._parentServer));
}
catch (e) {
reject(e);
}
});
}
delete() {
return new Promise(async (resolve, reject) => {
try {
resolve(await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/databases/${this.id}`, method: "DELETE" }));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = Database;