Function
Functions allow you to create serverless routines to transform your data using a custom pipeline. For example, you might want to clean, aggregate, or enrich telemetry data before sending it to another component or storing it in the platform. Functions are especially useful when you need to automate data processing without managing infrastructure.
You can create, update, or delete functions to define how and when the transformation should happen. Once configured, the function will automatically run whenever new data is available, applying the logic you’ve defined in your custom pipeline.
Creating a Function
To create a function, you need to specify the following parameters:
name
The name of the function.
Yes
description
A description of the function.
No
tags
Tags to be associated with the function.
No
function_items
The items that will be used to trigger the function.
Yes (when updating)
curl --request POST \
--url https://api.splight.com/v3/engine/function/functions/ \
--header 'authorization: Splight <access_id> <secret_key>' \
--header 'content-type: application/json' \
--data '{
"name": "<name>",
"description": "<description>",
"tags": ["<tags>"],
"function_items": ["<function_items>"]
}'
Reading a Function
Listing all Functions
curl --request GET \
--url https://api.splight.com/v3/engine/function/functions/ \
--header 'authorization: Splight <access_id> <secret_key>'
Retrive a single Function
To retrieve a single function, you can use the function ID in the URL. This will return detailed information about that specific function.
curl --request GET \
--url https://api.splight.com/v3/engine/function/functions/<function_id>/ \
--header 'authorization: Splight <access_id> <secret_key>'
Updating a Function
To update a function, you can use the function ID in the URL and specify the fields you want to update. You can update any of the fields that were used to create the function or add new ones. These options are available for updating:
name
The name of the function.
No
description
A description of the function.
No
tags
Tags to be associated with the function.
No
function_items
The items that will be used to trigger the function. Optional when creating the function, but required when updating.
Yes (when updating)
status
The status of the function.
No
active
Whether the function is active or not.
No
type
The type of the function.
No
time_window
The time window for the function.
No
target_variable
The target variable for the function.
No
target_asset
The target asset for the function (name and id).
No
target_attribute
The target attribute for the function (name, id, and type).
No
rate_value
The rate value for the function.
No
rate_unit
The rate unit for the function.
No
You can also add new function items or remove existing ones by specifying the deleted
field.
The function_items
field is an array of objects, each containing the following fields:
id
The ID of the function item.
query_filter_asset
The asset to filter the query.
query_filter_attribute
The attribute to filter the query.
query_filter_metadata
The metadata to filter the query.
ref_id
The reference ID for the function item.
label
The label for the function item.
type
The type of the function item.
expression
The expression for the function item.
expression_plain
The plain expression for the function item.
query_group_unit
The unit for grouping the query.
query_group_function
The function for grouping the query.
query_sort_field
The field to sort the query.
query_sort_direction
The direction to sort the query.
query_plain
The plain query for the function item.
deleted
Whether the function item is deleted or not.
```bash
curl --request PATCH \
--url https://api.splight.com/v3/engine/function/functions/<function_id>/ \
--header 'authorization: Splight <access_id> <secret_key>' \
--header 'content-type: application/json' \
--data '{
"name": "<name>",
"description": "<description>",
"status": "<status>",
"active": <true_or_false>,
"type": "<type>",
"time_window": <time_window>,
"target_variable": "<target_variable>",
"target_asset": {
"id": "<asset_id>",
"name": "<asset_name>"
},
"target_attribute": {
"id": "<attribute_id>",
"name": "<attribute_name>",
"type": "<attribute_type>"
},
"function_items": [
{
"id": "<function_item_id>",
"query_filter_asset": <query_filter_asset_or_null>,
"query_filter_attribute": <query_filter_attribute_or_null>,
"query_filter_metadata": <query_filter_metadata_or_null>,
"ref_id": "<ref_id>",
"label": "<label>",
"type": "<function_item_type>",
"expression": "<expression>",
"expression_plain": "<expression_plain>",
"query_group_unit": "<query_group_unit>",
"query_group_function": "<query_group_function>",
"query_sort_field": "<query_sort_field>",
"query_sort_direction": <query_sort_direction>,
"query_plain": "<query_plain>",
"deleted": <true_or_false>
}
// Add more function_items as needed
],
"tags": [
"<tag1>",
"<tag2>"
// Add more tags as needed
],
"rate_value": <rate_value>,
"rate_unit": "<rate_unit>"
}'
Deleting a Function
To delete a function, you can use the function ID in the URL. This will remove the function from your account.
curl --request DELETE \
--url https://api.splight.com/v3/engine/function/functions/<function_id>/ \
--header 'authorization: Splight <access_id> <secret_key>' \
Last updated
Was this helpful?