This class allows for managing alarms.

Hierarchy (view full)

Constructors

Methods

  • Gets the number of alarms based on the filter criteria.

    Parameters

    • filter: AlarmQueryFilter = {}

      Filters to query alarms.

      Example


      const filter: AlarmQueryFilter = {
      severity: Severity.MAJOR,
      };

      (async () => {
      const {data, res} = await alarmService.count(filter);
      })();

    Returns Promise<IResult<number>>

    Response wrapped in [[IResultList]]

  • Creates a new alarm.

    Parameters

    • entity: IAlarm

      Alarm object with mandantory fragments.

    Returns Promise<IResult<IAlarm>>

    Response wrapped in [[IResult]]

    Example


    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);
    })();
  • Gets the details of selected alarms.

    Parameters

    • entityOrId: string | number | IIdentified

      Entity or Id of the entity.

    Returns Promise<IResult<IAlarm>>

    Response wrapped in [[IResult]]

    Example


    const alarmId: number = 1;

    (async () => {
    const {data, res} = await alarmService.detail(alarmId);
    })();
  • Updates alarm data.

    Parameters

    • entity: Partial<IAlarm>

      Partial alarm to update, must have id.

    Returns Promise<IResult<IAlarm>>

    Response wrapped in [[IResult]]

    Example


    const partialUpdateObject: Partial<IAlarm> = {
    id: 123,
    severity: Severity.MINOR,
    source: device,
    text: 'Changed Alarm!'
    };

    (async () => {
    const {data, res} = await alarmService.update(partialUpdateObject);
    })();
  • Updates alarm data in bulk and with additional query filters.

    Parameters

    Returns Promise<IFetchResponse>

    Response in form of { IFetchResponse }

    Example


    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.