UNPKG

manageengine-mdm

Version:

A TypeScript wrapper for the ManageEngine Mobile Device Manager Plus API

110 lines (109 loc) 4.35 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlocklistAPI = void 0; const axios_1 = __importDefault(require("axios")); class BlocklistAPI { constructor(baseUrl, authManager, accountsServer) { this.baseUrl = baseUrl; this.authManager = authManager; this.accountsServer = accountsServer; } getHeaders() { return __awaiter(this, void 0, void 0, function* () { const token = yield this.authManager.getValidToken(this.accountsServer); return { Authorization: `Zoho-oauthtoken ${token}`, 'Content-Type': 'application/json', }; }); } /** * Get the apps available for blocklisting in the Inventory */ listBlocklistApps() { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.get(`${this.baseUrl}/api/v1/mdm/blacklist/apps`, { headers }); return response.data; }); } /** * Add new apps to be blocklisted */ addBlocklistApps(request) { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/blacklist/apps`, request, { headers }); return response.data; }); } /** * Blocklist apps on specific devices */ blocklistDevices(request) { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/blacklist/devices`, request, { headers }); return response.data; }); } /** * Remove blocklisted apps from devices */ removeBlocklistFromDevices(request) { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/blacklist/devices`, { headers, data: request, }); return response.data; }); } /** * Blocklist apps from groups */ blocklistGroups(request) { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/blacklist/groups`, request, { headers }); return response.data; }); } /** * Remove blocklisted apps from groups */ removeBlocklistFromGroups(request) { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/blacklist/groups`, { headers, data: request, }); return response.data; }); } /** * Get the status of blocklist actions on devices */ getBlocklistStatus() { return __awaiter(this, void 0, void 0, function* () { const headers = yield this.getHeaders(); const response = yield axios_1.default.get(`${this.baseUrl}/api/v1/mdm/blacklist/status`, { headers }); return response.data; }); } } exports.BlocklistAPI = BlocklistAPI;