@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
162 lines • 4.62 kB
JavaScript
import { __awaiter } from "tslib";
import { Service } from '../core/index.js';
/**
* This class allows for managing bulk operations.
*/
export class OperationBulkService extends Service {
constructor() {
super(...arguments);
this.baseUrl = 'devicecontrol';
this.listUrl = 'bulkoperations';
this.propertyName = 'bulkOperations';
}
/**
* Gets the details of selected bulk operation.
*
* @param {string|number|IIdentified} entityOrId Entity or Id of the entity.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const bulkOperationId: number = 1;
*
* (async () => {
* const {data, res} = await operationBulkService.detail(bulkOperationId);
* })();
* ```
*/
detail(operationOrId) {
const _super = Object.create(null, {
detail: { get: () => super.detail }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.detail.call(this, operationOrId);
});
}
/**
* Creates a new operation.
*
* @param {Partial<IOperationBulk>} operation Operation object with mandantory fragments.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const mandantoryObject: Partial<IOperationBulk> = {
* creationRamp: 15,
* groupId: '149044',
* operationPrototype: {
* c8y_Restart: {},
* description: 'Restart device',
* deviceId: device.id,
* status: 'PENDING'
* },
* startDate: '2018-02-15T16:01:00.000Z'
* };
*
* (async () => {
* const {data, res} = await operationBulkService.create(mandantoryObject);
* })();
* ```
*/
create(operation) {
const _super = Object.create(null, {
create: { get: () => super.create }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.create.call(this, operation);
});
}
/**
* Updates a new operation.
*
* @param {Partial<IOperationBulk>} operation Operation object.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const updateObject: Partial<IOperationBulk> = {
* creationRamp: 15,
* groupId: '149044',
* operationPrototype: {
* c8y_Restart: {},
* description: 'Restart device',
* deviceId: device.id,
* status: 'PENDING'
* },
* startDate: '2018-02-15T16:01:00.000Z'
* };
*
* (async () => {
* const {data, res} = await operationBulkService.update(updateObject);
* })();
* ```
*/
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 bulk operations filtered by parameters.
*
* @returns Response wrapped in [[IResultList]]
*
* @param {object} filter Object containing filters for querying alarms.
*
* **Example**
* ```typescript
*
* const filter: object = {
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await operationBulkService.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);
});
}
/**
* Removes an bulk operation with given id.
*
* @returns Response wrapped in [[IResult]]
*
* @param {string | number | IIdentified):} operationOrId Operation object or id.
*
* **Example**
* ```typescript
*
* const id: number = 1;
*
* (async () => {
* const {data, res} = await operationBulkService.delete(id);
* })();
* ```
*/
delete(operationOrId) {
const _super = Object.create(null, {
delete: { get: () => super.delete }
});
return __awaiter(this, void 0, void 0, function* () {
return _super.delete.call(this, operationOrId);
});
}
}
//# sourceMappingURL=OperationBulkService.js.map