Creating and updating events by using the Helix REST API
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
- Log in to BMC Helix Operations Management product.
- From the Signed in as list, select API Keys.
The API keys window opens. - Click Add key.
- In the API key name field, enter a key name.
- In the Key expiry field, enter a value.
Click Confirm. The API key is created.
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:
|
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.
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:
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:
Returns
A boolean indicating if the operation succeeded.
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