
Overview
Actions allow you to deploy serverless Python functions that can be triggered on-demand by endpoints or used as tools by AI agents. Think of actions as lambda-like functions that run in isolated environments.- Project Structure
my-project
config.yml
actions
send_mail_action.py
What Are Actions?
Actions are custom Python functions that run in isolated environments, accept parameters, return structured results, and can be triggered via endpoints or used as agent tools.Use Cases
- Send notifications
- Process data
- Call external APIs
- Generate reports
- Automate workflows
- Extend AI agent capabilities with custom logic
Action with Logging
Usecontext to log information during execution:
Action with Optional Parameters
Actions SDK Reference
Decorator
@action decorator marks a function as executable by Datazone.
Context API
The context object provides logging capabilities during action execution:function
Log informational messages during action execution.
function
Log warning messages for potential issues.
function
Log error messages when operations fail.
Variable API
The Variable class allows actions to access secure variables stored in Datazone:class
Access workspace variables securely within actions.
Example: Using Variables
Security Best Practice: Always store sensitive credentials as Variables rather than hardcoding them in your action code.
execute_query
Theexecute_query function runs SQL queries against your Datazone datasets and returns structured results:
function
Execute a SQL query against Datazone datasets.Returns a
QueryResult object with:data— list of row dictionariesstatus— execution status string
Example: Query and Transform
KnowledgeObject
TheKnowledgeObject client reads and writes Knowledge Object instances from within an action. Instances are addressed by their opaque _key, and operations run on the action’s project (main branch by default).
class
Access instances of a knowledge object by name.Methods:
get(key, add_relationships=False)— fetch one instance (adict) by its_key.list(filters=None, page=1, page_size=50, fields=None)— iterate pages of instances (see below).update(key, payload)— partially update an instance; returns the updated instance.delete(key)— delete an instance by its_key.batch_upsert(payloads)— insert/update up to 1000 instances in one call; returns{"created", "updated", "total"}.
list(...) returns an iterator of pages; each page exposes .items and .total_count. filters is a list of {"column", "operator", "value"} objects combined with AND (operators: equal, not_equal, contains, not_contains, greater_than, less_than).
Example: Read and upsert
FileContainerClient
FileContainerClient provides access to files stored in the Datazone file container (LakeFS/S3-compatible storage). It is automatically initialized as file_client in agent code execution environments — no import is required.
file_client is pre-initialized in agent code execution contexts. It is not available inside @action decorated functions.method
Fetch raw bytes for a file from the file container.
path— path relative to the file container root- Returns raw
bytes - Raises
ValueErrorif the file exceeds 10 MB or cannot be fetched
Examples: Reading Different File Types
CloudFeedClient
CloudFeedClient is a simplified SAP connector for reading tables and executing function modules from within actions:
class
SAP CloudFeed client for table access and function execution.Constructor parameters:
base_url— base URL of the SAP systemusername— SAP usernamepassword— SAP passwordtimeout(optional) — request timeout in seconds (default: 30)max_retries(optional) — max retries on failure (default: 10)backoff_factor(optional) — exponential backoff factor (default: 0.3)
Example: Query SAP Sales Orders
Example: Execute SAP Function Module
Example: Search and Inspect SAP Tables
Configuration
Add to config.yaml
Register your actions inconfig.yaml:
Repository Structure
config.yml
actions
send_email.py
process_data.py
generate_report.py
workflows
Each file should contain one
@action decorated function. Action function names must be unique within your project.Return Values
Actions should return structured data (dict, list, or primitives):Error Handling
Actions can raise exceptions - they’ll be captured and returned:Using Actions
1. In Endpoints
Connect actions to API endpoints for webhook-style triggers:2. In Agents
Enable actions as tools for AI agents: When creating an agent:- Select “Action” in the tools section
- Choose which actions the agent can use
- The agent will automatically call actions when needed
Examples
Slack Notification
Data Validation
API Integration
Next Steps
- Create Action Endpoints
- Use Actions in Agents
- Manage Variables - Store secure credentials and configuration
- Learn About Projects