@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
140 lines • 3.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OperationBulkService = void 0;
const index_js_1 = require("../core/index.js");
/**
* This class allows for managing bulk operations.
*/
class OperationBulkService extends index_js_1.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);
* })();
* ```
*/
async detail(operationOrId) {
return super.detail(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);
* })();
* ```
*/
async create(operation) {
return super.create(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);
* })();
* ```
*/
async update(entity) {
return super.update(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);
* })();
* ```
*/
async list(filter = {}) {
return super.list(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);
* })();
* ```
*/
async delete(operationOrId) {
return super.delete(operationOrId);
}
}
exports.OperationBulkService = OperationBulkService;
//# sourceMappingURL=OperationBulkService.js.map