@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
96 lines • 2.75 kB
JavaScript
import { __awaiter } from "tslib";
import { Service } from '../core/index.js';
export class AuditService extends Service {
constructor() {
super(...arguments);
this.baseUrl = 'audit';
this.listUrl = 'auditRecords';
this.propertyName = 'auditRecords';
}
/**
* Gets the details of selected audit record.
*
* @param {string|number|IAuditRecord} entityOrId Entity or Id of the entity.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const auditId: number = 1;
*
* (async () => {
* const {data, res} = await auditService.detail(auditId);
* })();
* ```
*/
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 audit record for a given source.
*
* @param {IAuditRecord} entity Audit record object with mandantory fragments.
* IAuditRecord implements the [[IEvent]] interface.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const mandantoryObject: IAuditRecord = {
* type: AuditRecordType.ALARM,
* time: '2018-05-02T10:08:00Z',
* severity: Severity.MAJOR,
* source: {id: 1}
* };
*
* (async () => {
* const {data, res} = await auditService.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);
});
}
/**
* Gets the list of audit records filtered by parameters.
*
* @returns Response wrapped in [[IResultList]]
*
* @param {object} filter Object containing filters for querying audit records.
*
* **Example**
* ```typescript
*
* const filter: object = {
* severity: Severity.MAJOR,
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await auditService.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=AuditService.js.map