UNPKG

pterowrap

Version:

A node.js wrapper for Pterodactyl API

57 lines (56 loc) 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Allocation { constructor(_client, data, _parentServer) { this._client = _client; this._parentServer = _parentServer; const attributes = data.attributes; this.id = attributes.id; this.ip = attributes.ip; this.ip_alias = attributes.ip_alias; this.port = attributes.port; this.notes = attributes.notes; this.is_default = attributes.is_default; this.raw = attributes; } setNote(note) { return new Promise(async (resolve, reject) => { try { const data = await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/network/allocations/${this.id}`, method: "POST", body: { notes: note }, }); resolve(new Allocation(this._client, data, this._parentServer)); } catch (e) { reject(e); } }); } setPrimary() { return new Promise(async (resolve, reject) => { try { const data = await this._client.call({ endpoint: `servers/${this._parentServer.identifier}/network/allocations/${this.id}/primary`, method: "POST", }); resolve(new Allocation(this._client, 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}/network/allocations/${this.id}`, method: "DELETE" })); } catch (e) { reject(e); } }); } } exports.default = Allocation;