UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

116 lines 3.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserInventoryRoleService = void 0; const index_js_1 = require("../core/index.js"); /** * @description * This service allows for managing current user's inventory roles. */ class UserInventoryRoleService extends index_js_1.Service { constructor(userUrl, client) { super(client); this.listUrl = `inventory`; this.currenUserUrl = `currentUser`; this.propertyName = 'inventoryAssignments'; this.baseUrl = `user/${userUrl}/roles`; } /** * Get a representation of a concrete current user's inventory role. * * @param {string|number|IUserInventoryRole} entityOrId inventory role id or inventory role object. * * @returns Returns promise object that is resolved with the IUserInventoryRole wrapped by IResult. * * **Example** * ```typescript * * const inventoryRoleId: number = 1; * * (async () => { * const {data, res} = await userInventoryRoleService.detail(inventoryRoleId); * })(); * ``` * * Required role: ROLE_TENANT_MANAGEMENT_READ<br><br> * User password is never returned in GET response. Authentication mechanism is provided by another interface. */ async detail(entityOrId) { return super.detail(entityOrId); } /** * Assign inventory role to current user. * * @param {IUserInventoryRole} entity Inventory Role object. * * @returns Returns promise object that is resolved with the details of newly assigned inventory role. * * **Example** * ```typescript * * const inventoryRoleObject: IUserInventoryRole = { * ... * }; * * (async () => { * const {data, res} = await userInventoryRoleService.create(inventoryRoleObject); * })(); * ``` */ async create(entity) { return super.create(entity); } /** * Updates an inventory role. * * @param {Partial<IUserInventoryRole>} entity Inventory Role object. */ async update(entity) { return super.update(entity); } /** * Gets the list the inventory roles applied to a current user. * * @param {object} filter Object containing filters for querying inventory roles. * * @returns Returns promise object that is resolved with the IUserInventoryRole wrapped by IResultList. * * **Example** * ```typescript * * const filter: object = { * severity: Severity.MAJOR, * pageSize: 100, * withTotalPages: true * }; * * (async () => { * const {data, res, paging} = await userInventoryRoleService.list(filter); * })(); * ``` */ async list(filter = {}) { return super.list(filter); } /** * Unassign inventory role from current user * * @param {string|number|IIdentified} entityOrId Inventory Role id or Inventory Role object. * * @returns Returns promise object that is resolved with the IResult. * * **Example** * ```typescript * * const inventoryRoleId: number = 1; * * (async () => { * const {data, res} = await userInventoryRoleService.delete(inventoryRoleId); * })(); * ``` */ async delete(entityOrId) { return super.delete(entityOrId); } } exports.UserInventoryRoleService = UserInventoryRoleService; //# sourceMappingURL=UserInventoryRoleService.js.map