node-firewalla
Version:
Package to talk your firewalla box & API
50 lines (49 loc) • 2.18 kB
JavaScript
import { FWGroupApi } from "../api/index.js";
import { FWCmdMessage, FWGetMessage } from "../models/index.js";
import { FWGroupService } from "./FWGroupService.js";
export class NetworkService extends FWGroupService {
async ping() {
let msg = new FWCmdMessage("ping");
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
/**
* @param {string} wanUUID - the UUID of the WAN interface to run the speedtest on
* @param {string} serverId - the ID of the remote server to run the speedtest on
* @param {boolean} noUpload - whether to skip upload for the speedtest
* @param {boolean} noDownload - whether to skip download for the speedtest
*/
async runSpeedtest(wanUUID = "", serverId = "", noUpload = false, noDownload = false) {
let msg = new FWCmdMessage("runInternetSpeedtest", { wanUUID, serverId, noUpload, noDownload });
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
/**
* @param {Date} begin - Only return speedtests after this date
*/
async getSpeedtestResults(begin = new Date(0)) {
let msg = new FWGetMessage("internetSpeedtestResults", { begin: (Number(begin) / 1000) });
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
async getMonthlyDataUsage() {
let msg = new FWGetMessage("monthlyDataUsage");
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
/**
* @param {Date} acl - ?? unknown parameter
*/
async getLast12MonthlyDateUsage(acl = true) {
let msg = new FWGetMessage("last12monthlyDataUsage", { acl });
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
async getNetworkMonitorData() {
let msg = new FWGetMessage("networkMonitorData");
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
async getDataPlan() {
let msg = new FWGetMessage("dataPlan");
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
async getMyPublicKey() {
let msg = new FWGetMessage("mypubkey");
return FWGroupApi.sendMessageToBox(this.fwGroup, msg);
}
}