Variables Functions Documentation

Variables Functions

A comprehensive Python set of functions for managing variables through HTTP API calls

GET get_variable

def get_variable(name)

Retrieves a specific variable by its name from the API.

📝 Parameters

name (str) - The name of the variable to retrieve

â†Šī¸ Returns

dict - The retrieved variable data, or None if not found

💡 Example

from tools.toolbox.variables import get_variable

variable = get_variable("myVariable")
if variable:
    print(f"Variable found: {variable}")
else:
    print("Variable not found")

GET get_all_variables

def get_all_variables()

Retrieves all variables from the API.

â†Šī¸ Returns

list - All variables data as a list of dictionaries

💡 Example

from tools.toolbox.variables import get_all_variables

all_variables = get_all_variables()

for variable in all_variables:
    for key, value in variable.items():
        print(f"{key}: {value}")

POST create_variable

def create_variable(data)

Creates a new variable with the specified data.

📝 Parameters

data (dict) - The variable data to create. Should be a dictionary with variable properties.

â†Šī¸ Returns

dict - The created variable data returned from the API

💡 Example

from tools.toolbox.variables import create_variable

new_variable = {
    "name": "temperature",
    "value": "25.5",
    "type": "number"
}

result = create_variable(new_variable)
print(f"Created variable: {result}")

PUT update_variable

def update_variable(name, new_value)

Updates an existing variable with a new value.

📝 Parameters

name (str) - The name of the variable to update
new_value (object) - The new value for the variable

â†Šī¸ Returns

dict - The updated variable data returned from the API

💡 Example

from tools.toolbox.variables import update_variable

# Update a variable with a new value
result = update_variable("temperature", "30.2")
print(f"Updated variable: {result}")

📤 Request Body Structure

The method automatically wraps the new value in a JSON object:

{
    "value": <new_value>
}