pterowrap
Version:
A node.js wrapper for Pterodactyl API
67 lines (66 loc) • 2.6 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AllocationManager_1 = __importDefault(require("../../managers/application/AllocationManager"));
class Node {
constructor(_client, data) {
this._client = _client;
const attributes = data.attributes;
this.id = attributes.id;
this.uuid = attributes.uuid;
this.public = attributes.public;
this.name = attributes.name;
this.description = attributes.description;
this.location_id = attributes.location_id;
this.fqdn = attributes.fqdn;
this.scheme = attributes.scheme;
this.behind_proxy = attributes.behind_proxy;
this.maintanance_mode = attributes.maintanance_mode;
this.memory = attributes.memory;
this.memory_overallocate = attributes.memory_overallocate;
this.disk = attributes.disk;
this.disk_overallocate = attributes.disk_overallocate;
this.upload_size = attributes.upload_size;
this.daemon_listen = attributes.daemon_listen;
this.daemon_sftp = attributes.daemon_sftp;
this.daemon_base = attributes.daemon_base;
this.created_at = attributes.created_at;
this.updated_at = attributes.updated_at;
this.allocated_resources = attributes.allocated_resources;
this.raw = attributes;
this.allocations = new AllocationManager_1.default(this._client, this);
}
retrieveWingsConfiguration() {
return new Promise(async (resolve, reject) => {
try {
resolve(await this._client.call({ endpoint: `nodes/${this.id}/configuration` }));
}
catch (e) {
reject(e);
}
});
}
update(params) {
return new Promise(async (resolve, reject) => {
try {
resolve(new Node(this._client, await this._client.call({ endpoint: "nodes/" + this.id, method: "PATCH", body: params })));
}
catch (e) {
reject(e);
}
});
}
delete() {
return new Promise(async (resolve, reject) => {
try {
resolve(await this._client.call({ endpoint: "nodes/" + this.id, method: "DELETE" }));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = Node;