browser-sdk
Version:
javascript SDK for the lightelligence-platform
109 lines (91 loc) • 3.07 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _apiService = _interopRequireDefault(require("../tools/apiService"));
/**
* Methods for roles operations
*/
class Role {
/**
* Get the permissions of the tenant
*
* @returns {Promise}
*/
static getPermissions() {
return _apiService.default.call('/permissions');
}
/**
* Get the roles of the tenant
*
* @param {object} [params] Search parameters
* @param {number} [params.page=0] The number of the page starting with 0
* @param {number} [params.pageSize=10] The number of result per page
* @returns {Promise}
*/
static getRoles() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var urlParams = new URLSearchParams(params);
return _apiService.default.call("/roles?".concat(urlParams.toString()));
}
/**
* Get the role of the tenant
*
* @param {string} roleId The role's UUID
* @returns {Promise}
*/
static getRole(roleId) {
return _apiService.default.call("/roles/".concat(roleId));
}
/**
* Create the role of the tenant
*
* @param {object} role The role data
* @param {string} role.name The name of the role
* @param {string} [role.description] The description of the role
* @param {Array<{ id: string, alias: string }>} [role.permissions] The permissions of the role. Either id or alias must be provided.
* @returns {Promise}
*/
static createRole(role) {
return _apiService.default.call("/roles", 'POST', role);
}
/**
* Delete the role of the tenant
*
* @param {string} roleId The role's UUID
* @returns {Promise}
*/
static deleteRole(roleId) {
return _apiService.default.call("/roles/".concat(roleId), 'DELETE');
}
/**
* Patch the role of the tenant
*
* @param {string} roleId The role's UUID
* @param {object} role The role data
* @param {string} [role.name] The name of the role
* @param {string} [role.description] The description of the role
* @param {Array<{ id: string, alias: string }>} [role.permissions] The permissions of the role. Either id or alias must be provided.
* @returns {Promise}
*/
static patchRole(roleId, role) {
return _apiService.default.call("/roles/".concat(roleId), 'PATCH', role);
}
/**
* Get the users of the role
*
* @param {string} roleId The role's UUID
* @param {object} [params] Search parameters
* @param {number} [params.page=0] The number of the page starting with 0
* @param {number} [params.pageSize=10] The number of result per page
* @returns {Promise}
*/
static getRoleUsers(roleId) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var urlParams = new URLSearchParams(params);
return _apiService.default.call("/roles/".concat(roleId, "/users?").concat(urlParams.toString()));
}
}
exports.default = Role;