manageengine-mdm
Version:
A TypeScript wrapper for the ManageEngine Mobile Device Manager Plus API
143 lines (142 loc) • 5.56 kB
JavaScript
"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.VppAPI = void 0;
const axios_1 = __importDefault(require("axios"));
class VppAPI {
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 details of all available/added location tokens
*/
getAllVppAccounts() {
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/apps/account/vpp`, { headers });
return response.data;
});
}
/**
* Add a new location token (VPP token)
*/
addVppAccount(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/apps/account/vpp`, request, { headers });
return response.data;
});
}
/**
* Remove all VPP accounts and their associated apps
*/
removeAllVppAccounts() {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/apps/account/vpp`, {
headers,
});
});
}
/**
* Get sync status of all VPP accounts
*/
getAllVppSyncStatus() {
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/apps/account/vpp/sync`, { headers });
return response.data;
});
}
/**
* Sync all VPP accounts
*/
syncAllVppAccounts() {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/apps/account/vpp/sync`, {}, { headers });
});
}
/**
* Get details of a specific VPP account
*/
getVppAccount(vppId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
const response = yield axios_1.default.get(`${this.baseUrl}/api/mdm/apps/account/vpp/${vppId}`, { headers });
return response.data;
});
}
/**
* Modify a VPP account
*/
modifyVppAccount(vppId, request) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.put(`${this.baseUrl}/api/mdm/apps/account/vpp/${vppId}`, request, { headers });
});
}
/**
* Remove a specific VPP account and its associated apps
*/
removeVppAccount(vppId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/mdm/apps/account/vpp/${vppId}`, {
headers,
});
});
}
/**
* Get failure details for apps that failed to sync
*/
getVppFailureDetails(vppId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
const response = yield axios_1.default.get(`${this.baseUrl}/api/mdm/apps/account/vpp/${vppId}/failure`, { headers });
return response.data;
});
}
/**
* Get sync status of a specific VPP account
*/
getVppSyncStatus(vppId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
const response = yield axios_1.default.get(`${this.baseUrl}/api/mdm/apps/account/vpp/sync/${vppId}`, { headers });
return response.data;
});
}
/**
* Sync a specific VPP account
*/
syncVppAccount(vppId, request) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.post(`${this.baseUrl}/api/mdm/apps/account/vpp/sync/${vppId}`, request, { headers });
});
}
}
exports.VppAPI = VppAPI;