UNPKG

@c8y/client

Version:

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

146 lines 4.37 kB
import { IIdentified, Service, IResult, IResultList, IFetchResponse } from '../core/index.js'; import { AlarmQueryFilter, IAlarm, UpdateBulkQueryFilter } from './IAlarm.js'; /** * This class allows for managing alarms. */ export declare class AlarmService extends Service<IAlarm> { protected baseUrl: string; protected listUrl: string; protected propertyName: string; protected channel: string; /** * Gets the details of selected alarms. * * @param {string|number|IIdentified} entityOrId Entity or Id of the entity. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const alarmId: number = 1; * * (async () => { * const {data, res} = await alarmService.detail(alarmId); * })(); * ``` */ detail(entityOrId: string | number | IIdentified): Promise<IResult<IAlarm>>; /** * Creates a new alarm. * * @param {IAlarm} entity Alarm object with mandantory fragments. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const mandantoryObject: IAlarm = { * severity: Severity.CRITICAL, * source: device, * text: 'I am an Alarm!', * time: '2018-05-02T10:08:00Z', * type: 'device-type-here', * }; * * (async () => { * const {data, res} = await alarmService.create(mandantoryObject); * })(); * ``` */ create(entity: IAlarm): Promise<IResult<IAlarm>>; /** * Updates alarm data. * * @param {Partial<IAlarm>} entity Partial alarm to update, must have `id`. * * @returns Response wrapped in [[IResult]] * * **Example** * ```typescript * * const partialUpdateObject: Partial<IAlarm> = { * id: 123, * severity: Severity.MINOR, * source: device, * text: 'Changed Alarm!' * }; * * (async () => { * const {data, res} = await alarmService.update(partialUpdateObject); * })(); * ``` */ update(entity: Partial<IAlarm>): Promise<IResult<IAlarm>>; /** * Updates alarm data in bulk and with additional query filters. * * @param {Partial<IAlarm>} entity Partial alarm object. * @param {Record<string, string | number | boolean>} filters Additional query filters. * * @returns Response in form of { IFetchResponse } * * **Example** * ```typescript * * const partialUpdateObject: Partial<IAlarm> = { * status: AlarmStatus.CLEARED * }; * * const additionalFilters: Record<string, string | number | boolean> = { * resolved: false, * severity: Severity.MINOR * }; * * (async () => { * const response = await alarmService.updateBulk(partialUpdateObject, additionalFilters); * })(); * ``` * In this example, every unresolved alarm that has a severity of `Severity.MINOR` will be updated with a status of `AlarmStatus.CLEARED`. */ updateBulk(entity: Partial<IAlarm>, filters: UpdateBulkQueryFilter): Promise<IFetchResponse>; /** * Gets the list of alarms filtered by parameters. * * @returns Response wrapped in [[IResultList]] * * @param {AlarmQueryFilter} filter Filters to query alarms. * * **Example** * ```typescript * * const filter: AlarmQueryFilter = { * severity: Severity.MAJOR, * pageSize: 100, * withTotalPages: true * }; * * (async () => { * const {data, res, paging} = await alarmService.list(filter); * })(); * ``` */ list(filter?: AlarmQueryFilter): Promise<IResultList<IAlarm>>; /** * Gets the number of alarms based on the filter criteria. * * @returns Response wrapped in [[IResultList]] * * @param {AlarmQueryFilter} filter Filters to query alarms. * * **Example** * ```typescript * * const filter: AlarmQueryFilter = { * severity: Severity.MAJOR, * }; * * (async () => { * const {data, res} = await alarmService.count(filter); * })(); * ``` */ count(filter?: AlarmQueryFilter): Promise<IResult<number>>; } //# sourceMappingURL=AlarmService.d.ts.map