UNPKG

@c8y/client

Version:

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

119 lines 3.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OperationService = void 0; const index_js_1 = require("../core/index.js"); /** * This class allows for managing operations on a device. */ class OperationService extends index_js_1.Service { constructor() { super(...arguments); this.baseUrl = 'devicecontrol'; this.listUrl = 'operations'; this.propertyName = 'operations'; } /** * Gets the details of selected operation. * * @param {string|number|IIdentified} entityOrId Entity or Id of the entitytabs.service.ts. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const operationId: number = 1; * * (async () => { * const {data, res} = await operationService.detail(operationId); * })(); * ``` */ async detail(entityOrId) { return super.detail(entityOrId); } /** * Creates a new operation. * * @param {IOperation} entity Operation object with mandantory fragments. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const mandantoryObject: IOperation = { * com_cumulocity_model_WebCamDevice: { * name: 'take picture', * parameters: { * duration: '5s', * quality: 'HD' * } * }, * deviceId: device.id, * }; * * (async () => { * const {data, res} = await operationService.create(mandantoryObject); * })(); * ``` */ async create(entity) { return super.create(entity); } /** * Updates operation data. * * @param {Partial<IOperation>} entity Operation is partially updatable. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const partialUpdateObject: Partial<IOperation> = { * com_cumulocity_model_WebCamDevice: { * name: 'take picture', * parameters: { * duration: '2s', * quality: 'HD', * ratio: '16:9' * } * }, * deviceId: device.id, * }; * * (async () => { * const {data, res} = await operationService.update(partialUpdateObject); * })(); * ``` */ async update(entity) { return super.update(entity); } /** * Gets the list of operations filtered by parameters. * * @returns Response wrapped in [[IResultList]] * * @param {object} filter Object containing filters for querying operations. * * **Example** * ```typescript * * const filter: object = { * pageSize: 100, * withTotalPages: true * }; * * (async () => { * const {data, res, paging} = await operationService.list(filter); * })(); * ``` */ async list(filter = {}) { return super.list(filter); } } exports.OperationService = OperationService; //# sourceMappingURL=OperationService.js.map