Creating and updating events by using the Helix REST API


This topic describes how to create and update events in the Helix database by using RDL functions in the Helix REST API.

For more information about managing REST API events, see Managing events with REST APIs.

Related topic

Before you begin

To make a successful API call you must make sure that the server's certificate has been imported to the trust store. Follow the steps in Importing-trusted-server-certificates.

To set up BMC Helix Operations Management to access REST API

  1. Log in to BMC Helix Operations Management product.
  2. From the Signed in as list, select API Keys.
    The API keys window opens.
  3. Click Add key.
  4. In the API key name field, enter a key name.
  5. In the Key expiry field, enter a value.
  6. Click Confirm. The API key is created.

    Important

    Make sure to save the API key name.

To create a Helix event

We can create a Helix event by the following function:

helixCreateEvent(hostAndPort, accessKey, accessSecretKey, data)

The parameters in this function are as follows:

Parameter

Description

hostAndPort

The host and port of Helix API URL.

accessKey

The access key for the Helix user account. 

accessSecretKey

The access secret key for the Helix user account. 

data

The request body for the API call.

The data parameter is an RDL property map that may contain the following:

Property

Description

class

The Helix event class. If omitted, the default is EVENT

severity

Helix severity level:

  • CRITICAL
  • MAJOR
  • MINOR
  • WARNING
  • INFO
  • OK
  • UNKNOWN

msg

The message of the text.

Other properties are also available. You can consult the Helix documentation for all possible properties and their values.

Returns

helixCreateEvent returns the Helix event identifier as a string. This id may be saved and used as the eventId parameter to the helixSendEvent function.

Example
trigger on message.MSGID == "ITT006A"

host = "helixhost.example.com"
apikey = "(apikey)"
apisecret = "(apisecretkey)"

event.class = "EVENT"
event.severity = "MAJOR"
event.object = "amicm_object"
event.msg = message.TEXT
event.source_identifier = "myhost.example.com:9101"

helixId = helixCreateEvent(host, apikey, apisecret, event)

To update a Helix event

Provide the slot names and values in the payload by using the following function:

helixUpdateEvent(hostAndPort, accessKey, accessSecretKey, eventId, data)

The parameters in this function are as follows:

Parameter

Description

hostAndPort

The host and port of Helix API URL

accessKey

The access key for the Helix user account

accessSecretKey

The access secret key for the Helix user account

eventId

The event ID of the Helix API

data

The request body for the API call

 The data parameter is an RDL property map containing the values that you want to change. For example, to close an event, set its status to CLOSED:

data.status = “CLOSED”

Returns

A boolean indicating if the operation succeeded.

Example
function closeHelix(helixId)

host = "helixhost.example.com"
apikey = "(apikey)"
apisecret = "(apisecretkey)"
eventUpdate.status = "CLOSED"
status = helixUpdateEvent(host, apikey, apisecret, helixId, eventUpdate)
if status == false then
writeToOperator("Helix error: " & helixGetLastError(), RED)
else
    writeToOperator("helixSendEvent succeeded.", BLUE)
endif
return true

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*