manageengine-mdm
Version:
A TypeScript wrapper for the ManageEngine Mobile Device Manager Plus API
151 lines (150 loc) • 6.18 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.ComplianceAPI = void 0;
const axios_1 = __importDefault(require("axios"));
class ComplianceAPI {
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 list of all fence profiles available
*/
listFenceProfiles() {
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/compliance`, { headers });
return response.data;
});
}
/**
* Add a new fence profile
*/
addFenceProfile(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/compliance`, request, { headers });
return response.data;
});
}
/**
* Delete multiple fence profiles
*/
deleteMultipleFenceProfiles(request) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/compliance`, {
headers,
data: request,
});
});
}
/**
* Get details of a specific fence profile
*/
getFenceProfileDetails(complianceId) {
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/compliance/${complianceId}`, { headers });
return response.data;
});
}
/**
* Modify a specific fence profile
*/
modifyFenceProfile(complianceId, request) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
const response = yield axios_1.default.put(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}`, request, { headers });
return response.data;
});
}
/**
* Delete a specific fence profile
*/
deleteFenceProfile(complianceId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}`, { headers });
});
}
/**
* Get the list of groups to which the Fence policy is associated
*/
getFenceGroups(complianceId) {
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/compliance/${complianceId}/groups`, { headers });
return response.data;
});
}
/**
* Associate Fence policy to multiple groups
*/
associateMultipleGroups(complianceId, request) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}/groups`, request, { headers });
});
}
/**
* Disassociate Fence policy from multiple groups
*/
disassociateMultipleGroups(complianceId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}/groups`, { headers });
});
}
/**
* Get devices under a specific group for a Fence policy
*/
getGroupDevices(complianceId, groupId) {
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/compliance/${complianceId}/groups/${groupId}`, { headers });
return response.data;
});
}
/**
* Associate Fence policy to a specific group
*/
associateGroup(complianceId, groupId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.post(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}/groups/${groupId}`, null, { headers });
});
}
/**
* Disassociate Fence policy from a specific group
*/
disassociateGroup(complianceId, groupId) {
return __awaiter(this, void 0, void 0, function* () {
const headers = yield this.getHeaders();
yield axios_1.default.delete(`${this.baseUrl}/api/v1/mdm/compliance/${complianceId}/groups/${groupId}`, { headers });
});
}
}
exports.ComplianceAPI = ComplianceAPI;