Components are the core building blocks of the Splight engine, as they are responsible for handling all data processing within the system.
They come in two main forms: algorithms, which transform and analyze data, and connectors, which pass data between components. Despite their different roles, both types share the same structure and are defined in the same way.
Each component includes a set of routines that are executed during runtime, enabling seamless interaction with the underlying infrastructure by sending and receiving data as needed.
There are many types of components available in Splight. If you're unsure which type best fits your needs, feel free to contact any member of the Splight team for guidance and support.
Creating a Component
To create a component, you need to specify the following parameters:
Parameter
Description
Required
component_name
The name of the component.
Yes
component_description
A description of the component.
No
component_version
The version of the component.
Yes
component_input
The inputs of the component.
Yes
component_output
The outputs of the component.
Yes
component_routine
The routines of the component.
Yes
deployment_capacity
The capacity of the component (small, medium, large).
Yes
custom_types
Custom types for the component.
No
endpoints
Endpoints of the component.
No
deployment_type
The type of deployment.
Yes
tags
Tags for the component.
No
We recomend creating the routines after creating the component. You can find more information in the section.
Where the input and output fields dependends on the component type.
Reading Components
The Splight API provides a comprehensive set of endpoints for reading component data. You can retrieve information about all components or filter them based on specific criteria. The API supports various query parameters to help you narrow down your search.
Let's explore some examples of how to read components using the API. Below are simple code snippets using curl and Python:
import requests
ACCESS_ID = "<user_access_id>" # Replace with your access ID
SECRET_KEY = "<user_secret_key>" # Replace with your secret key
COMPONENT_TYPE = "<component_type>" # Replace with your component type in plural
url = f"https://api.splight.com/v3/engine/component/{COMPONENT_TYPE}"
headers = {
"authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code) # 200 indicates successful retrieval
Where component_type is the type of the component (e.g., "algorithm", "connector"). If you want to retrieve all components, you can omit this parameter.
import requests
ACCESS_ID = "<user_access_id>" # Replace with your access ID
SECRET_KEY = "<user_secret_key>" # Replace with your secret key
COMPONENT_TYPE = "<component_type>" # Replace with your component type in plural
COMPONENT_ID = "<component_id>" # Replace with your component ID
url = f"https://api.splight.com/v3/engine/component/{COMPONENT_TYPE}/{COMPONENT_ID}"
payload = {
"name": "<component_name>",
"description": "<component_description>",
"version": "<component_version>",
"deployment_capacity": "<deployment_capacity>",
"custom_types": [],
"input": [
"<component_input>"
],
"output": [
"<component_output>"
],
"routines": [
"<component_routine>"
],
"endpoints": [],
"deployment_type": "SPLIGHT_HOSTED",
"tags": []
}
headers = {
"authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())
print(response.status_code) # 200 indicates successful update
All fields are the same as in the creation process and all of them can be updated, except for the component_id, which is required to identify the component being updated and cannot be changed.
import requests
ACCESS_ID = "<user_access_id>" # Replace with your access ID
SECRET_KEY = "<user_secret_key>" # Replace with your secret key
ROUTINE_ID = "<routine_id>" # Replace with your routine ID
COMPONENT_ID = "<component_id>" # Replace with your component ID
url = f"https://api.splight.com/v3/engine/component/routines/{ROUTINE_ID}"
payload = {
"name": "<routine_name>",
"description": "<routine_description>",
"component_id": COMPONENT_ID,
"type": "<routine_type>",
"config": [
"<routine_config>"
],
"input": [
"<routine_input>"
],
"output": [
"<routine_output>"
]
}
headers = {
"authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())
print(response.status_code) # 200 indicates successful update
All fields are the same as in the creation process and all of them can be updated, except for the routine_id, which is required to identify the routine being updated and cannot be changed.