JavaScript
import Riza from '@riza-io/api';
const client = new Riza({
apiKey: process.env['RIZA_API_KEY'], // This is the default and can be omitted
});
const response = await client.command.execFunc({
code: 'def execute(input): return { "name": input["name"], "executed": True }',
language: 'python',
input: { name: 'John' },
});
console.log(response.execution);import os
from rizaio import Riza
client = Riza(
api_key=os.environ.get("RIZA_API_KEY"), # This is the default and can be omitted
)
response = client.command.exec_func(
code="def execute(input): return { \"name\": input[\"name\"], \"executed\": True }",
language="python",
input={
"name": "John"
},
)
print(response.execution)package main
import (
"context"
"fmt"
"github.com/riza-io/riza-api-go"
"github.com/riza-io/riza-api-go/option"
)
func main() {
client := riza.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("RIZA_API_KEY")
)
response, err := client.Command.ExecFunc(context.TODO(), riza.CommandExecFuncParams{
Code: riza.F(`def execute(input): return { "name": input["name"], "executed": True }`),
Language: riza.F(riza.CommandExecFuncParamsLanguagePython),
Input: riza.F[any](map[string]interface{}{
"name": "John",
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Execution)
}
{
"output": {
"name": "John",
"executed": true
},
"output_status": "valid",
"execution": {
"id": "",
"exit_code": 0,
"stdout": "",
"stderr": "",
"duration": 7
}
}{
"code": 16,
"message": "unauthenticated"
}Code
Execute function
Run a function in a secure, isolated environment. Define a function named execute. The function will be passed input as an object.
JavaScript
import Riza from '@riza-io/api';
const client = new Riza({
apiKey: process.env['RIZA_API_KEY'], // This is the default and can be omitted
});
const response = await client.command.execFunc({
code: 'def execute(input): return { "name": input["name"], "executed": True }',
language: 'python',
input: { name: 'John' },
});
console.log(response.execution);import os
from rizaio import Riza
client = Riza(
api_key=os.environ.get("RIZA_API_KEY"), # This is the default and can be omitted
)
response = client.command.exec_func(
code="def execute(input): return { \"name\": input[\"name\"], \"executed\": True }",
language="python",
input={
"name": "John"
},
)
print(response.execution)package main
import (
"context"
"fmt"
"github.com/riza-io/riza-api-go"
"github.com/riza-io/riza-api-go/option"
)
func main() {
client := riza.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("RIZA_API_KEY")
)
response, err := client.Command.ExecFunc(context.TODO(), riza.CommandExecFuncParams{
Code: riza.F(`def execute(input): return { "name": input["name"], "executed": True }`),
Language: riza.F(riza.CommandExecFuncParamsLanguagePython),
Input: riza.F[any](map[string]interface{}{
"name": "John",
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Execution)
}
{
"output": {
"name": "John",
"executed": true
},
"output_status": "valid",
"execution": {
"id": "",
"exit_code": 0,
"stdout": "",
"stderr": "",
"duration": 7
}
}{
"code": 16,
"message": "unauthenticated"
}Authorizations
Body
application/json
Response
OK
The status of the output. "valid" means your function executed successfully and returned a valid JSON-serializable object, or void. "json_serialization_error" means your function executed successfully, but returned a nonserializable object. "error" means your function failed to execute.
Available options:
error, json_serialization_error, valid