@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
136 lines • 3.78 kB
JavaScript
import { __awaiter } from "tslib";
import { Service } from '../core/index.js';
/**
* This class allows for managing operations on a device.
*/
export class OperationService extends 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);
* })();
* ```
*/
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);
});
}
/**
* 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);
* })();
* ```
*/
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 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);
* })();
* ```
*/
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 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);
* })();
* ```
*/
list() {
const _super = Object.create(null, {
list: { get: () => super.list }
});
return __awaiter(this, arguments, void 0, function* (filter = {}) {
return _super.list.call(this, filter);
});
}
}
//# sourceMappingURL=OperationService.js.map