UNPKG

@c8y/client

Version:

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

138 lines 4.35 kB
import { __awaiter } from "tslib"; import { Service } from '../core'; /** * @description * This service allows for managing current user's inventory roles. */ export class UserInventoryRoleService extends 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. */ detail(entityOrId) { const _super = Object.create(null, { detail: { get: () => super.detail } }); return __awaiter(this, void 0, void 0, function* () { return _super.detail.call(this, 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); * })(); * ``` */ create(entity) { const _super = Object.create(null, { create: { get: () => super.create } }); return __awaiter(this, void 0, void 0, function* () { return _super.create.call(this, entity); }); } /** * Updates an inventory role. * * @param {Partial<IUserInventoryRole>} entity Inventory Role object. */ update(entity) { const _super = Object.create(null, { update: { get: () => super.update } }); return __awaiter(this, void 0, void 0, function* () { return _super.update.call(this, 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); * })(); * ``` */ list() { const _super = Object.create(null, { list: { get: () => super.list } }); return __awaiter(this, arguments, void 0, function* (filter = {}) { return _super.list.call(this, 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); * })(); * ``` */ delete(entityOrId) { const _super = Object.create(null, { delete: { get: () => super.delete } }); return __awaiter(this, void 0, void 0, function* () { return _super.delete.call(this, entityOrId); }); } } //# sourceMappingURL=UserInventoryRoleService.js.map