Managing global variables with REST APIs
The following section provides a list of supported endpoints and an overview about running these endpoints. Before you run an endpoint, you must authenticate yourself. For more information, see Access and authentication for the REST API
Managing global variables for event enrichment policies
You can create, update, delete, and retrieve global variables by running APIs. You can also modify attributes of global variables by running APIs.
POST /global_variables
Create a global variable
Important
Make sure that you specify the request body only in the English locale.
Authorization: Bearer <JWT_token>
For instructions about obtaining the JWT token, see Access and authentication for the REST API.
Parameter details
Request body
"name": "String",
"description": "String",
"attributes": [
{
"name": "String",
"dataType": "String",
"defaultValue": "String",
"value": "String"
}
]
}
Example request body
"name": "mom_records",
"description": "MOMInformation",
"attributes": [
{
"name": "timeframe_heartbeats",
"dataType": "STRING",
"defaultValue": "",
"value": "86400"
},
{
"name": "amount_heartbeats",
"dataType": "STRING",
"defaultValue": "6",
"value": ""
}
]
}
Successful response
"message": "[Successfully created Global Variable.]",
"object": {
"name": "[mom_records]"
}
}
Unsuccessful responses
Scenario 1: You specify a duplicate global variable name
"message": "[Failed to create global variable entry, entry with same id already exists for tenant 936425861 and name mom_records.]",
"errorCode": "GLOBAL_VARIABLE_ALREADY_EXIST"
}
Scenario 2: You specify an empty or null value in the global variable name
"message": "Global Variable Name Passed as empty/null",
"errorCode": "EMPTY_NULL_GLOBAL_VARIABLE_NAME"
}
Scenario 3: You specify an empty or null value for an attribute name in the global variable
"message": "Attribute Name seems to be empty/null",
"errorCode": "EMPTY_GLOBAL_VARIABLE_ATTRIBUTE_NAME"
}
Scenario 4: You specify an invalid global variable name
"message": "Invalid Naming Convention : record$$$_1",
"errorCode": "NAMING_CONVENTION_NOT_PROPER"
}
PUT /global_variables/?updateOption=<Update Option>
Update a global variable
Important
Make sure that you specify the request body only in the English locale.
When you update a global variable, you can partially or completely override attributes in the global variable. To add or remove values from the enumeration, send the entire enumeration request payload with the required values. To learn more about the request payload, see Example request body.
Authorization: Bearer <JWT_token>
For instructions about obtaining the JWT token, see Access and authentication for the REST API.
Parameter details
Request body
"name": "String",
"description": "String",
"attributes": [
{
"name": "String",
"dataType": "String",
"defaultValue": "String",
"value": "String"
}
]
}
Example request body
To partially update a global variable
In this example, a new attribute heartbeat_threshold_count is added to the mom_records global variable. To add this new attribute, send the entire variable request payload with the required values.
"name": "mom_records",
"description": "MOMInformation",
"attributes": [
{
"name": "timeframe_heartbeats",
"dataType": "STRING",
"defaultValue": "",
"value": "86400"
},
{
"name": "amount_heartbeats",
"dataType": "STRING",
"defaultValue": "6",
"value": ""
},
{
"name": "heartbeat_threshold_count",
"dataType": "STRING",
"defaultValue": "100",
"value": "300"
}
]
}
To override an existing attribute of a global variable
Overriding an existing attribute replaces the entire attribute definition similar to overwriting the changes in a file. To override an existing attribute, send the entire variable request payload with the required values.
"name": "mom_records",
"description": "MOMInformation",
"attributes": [
{
"name": "ping_heartbeats",
"dataType": "STRING",
"defaultValue": "",
"value": "103200"
}
]
}
Successful response
"message": "[Successfully updated Global Variable.]",
"object": {
"name": "[mom_records]"
}
}
Unsuccessful responses
Scenario 1: You do not specify the mandatory parameter updateOption in the API request URL
{
"key": "validation.request.parameter.query.missing",
"level": "ERROR",
"message": "Query parameter 'updateOption' is required on path '/v1.0/global_variables' but not found in request.",
"additionalInfo": []
}
]
Scenario 2: You attempt to change the data type of an existing attribute in the global variable
"message": "[Data type of timeframe_heartbeatsv3 cannot be changed for tenant 936425861 and global variable name Scomrecords5.]",
"errorCode": "DATA_TYPE_CANNOT_BE_CHANGED"
}
GET /global_variables/{name}/values
Get a global variable by variable name
Authorization: Bearer <JWT_token>
Parameter details
Successful response
"message": "[Global Variable entry found successfully for specified name.]",
"object": [
{
"name": "timeframe_heartbeats",
"dataType": "STRING",
"value": "86400"
},
{
"name": "amount_heartbeats",
"dataType": "STRING",
"value": "6"
}
]
}
Unsuccessful response
Scenario: You specify a variable name that does not exist
"message": "[No Global Variable entry for matching input request.]",
"errorCode": "400"
}
GET /global_variables
Get details of all global variables
Authorization: Bearer <JWT_token>
For instructions about obtaining the JWT token, see Access and authentication for the REST API.
Successful response
"message": "[Global Variables found.]",
"object": [
{
"name": "mom_records",
"description": "MOM Information",
"attributes": [
{
"name": "invdata_last_run",
"dataType": "STRING",
"defaultValue": "",
"value": "1644844433"
}
]
},
{
"name": "scom_records",
"description": "SCOM Information",
"attributes": [
{
"name": "amount_heartbeats",
"dataType": "STRING",
"defaultValue": "",
"value": "10"
}
]
}
]
}
DELETE /global_variables/{name}
Delete a global variable
Authorization: Bearer <JWT_token>
For instructions about obtaining the JWT token, see Access and authentication for the REST API.
Parameter details
Successful responses
"message": "[Successfully deleted Global Variable.]",
"object": {
"name": "[mom_records]"
}
}
Unsuccessful response
Scenario: You specify a variable name that already exists or is deleted
"message": "[Requested Global variable does not exist or already deleted]",
"errorCode": "400"
}
PUT /global_variables/{name}/values
Update an existing attribute in a global variable
Authorization: Bearer <JWT_token>
For instructions about obtaining the JWT token, see Access and authentication for the REST API.
Parameter details
Request body
{
"name": "String",
"value": "String"
}
]
Example request body
{
"name": "timeframe_heartbeats",
"value": "86700"
},
{
"name": "amount_heartbeats",
"value": "15"
}
]
Successful response
"message": "[Successfully updated Global Variable.]",
"object": {
"name": "[mom_records]"
}
}
Unsuccessful responses
Scenario 1: You specify a variable name that does not exist
"message": "[Failed to get existing global variable entry for tenant 1980396036 and name record_11.]",
"errorCode": "GLOBAL_VARIABLE_NOT_EXIST"
}