# FuncApi (Function APIs)

## executeFunction

Execute a specific Trillo function by providing its parameters.​

```
FuncApi.executeFunction(String functionName, Map params)

or

FuncApi.executeFunction(String appName, String functionName, Map<String, Object> params)
```

parameters:

```
functionName: name of the function
params:   hashmap representing the parameters
appName
```

**Sample Code**

<pre class="language-java"><code class="lang-java">Map&#x3C;String, Object> functionParameters = new LinkedHashMap&#x3C;String, Object>(); 
<strong>Result result = FuncApi.executeFunction("FUNCTION_NAME", functionParameters);
</strong></code></pre>

**Returns**:

```
object values returned by the called function​
```

## executeFunctionWithMethod

Description...

```
FuncApi.executeFunctionWithMethod(String functionName, String methodName, 
Map<String, Object> params)

or

FuncApi.executeFunctionWithMethod(String appName, String functionName, String methodName,
Map<String, Object> params)
```

#### Parameters

```
functionName
methodName
params
appName
```

**Sample Code**

<pre class="language-java"><code class="lang-java">Map&#x3C;String, Object> functionParameters = new LinkedHashMap&#x3C;String, Object>(); 
<strong>Result result = FuncApi.executeFunctionWithMethod("FUNCTION_NAME", "METHOD_NAME", functionParameters);
</strong>
</code></pre>

**Returns**

```
// Some code
```

## executeSSH

Execute a remote ssh command on a server whose keys are known to the workbench.​ Generally the SSH server is a companion server of the workbench.

```
FuncApi.executeSSH(String hostName, String command)

or

FuncApi.executeSSH(String hostName, String command, boolean async)

or

FuncApi.executeSSH(String command, boolean async)
```

parameters:

```
hostName: the name of the companion server
command:   the command needed to be executed
async:     execute command immediately and wait or run it in the background
```

**Returns**:

```
the result of the ssh command​
```

## pingTask

Ping an asynchronous task by id​ and returns it's last time stamp

```
FuncApi.pingTask(String id)
```

parameters:

```
id: task name
```

**Sample Code**

<pre class="language-java"><code class="lang-java">
<strong>Object result = FuncApi.pingTask("id");
</strong>
</code></pre>

**Returns**:

```
the value of the timestamp​
```

## createTask

Description...

```
FuncApi.createTask(String taskName, String taskType, String functionName, Map<String, 
Object> params)

or

FuncApi.createTask(String taskName, String taskType, String appName, String functionName, 
Map<String, Object> params)
```

#### Parameters

```
taskName
taskType
functionName
params
appName
```

**Sample Code**

<pre class="language-java"><code class="lang-java">
<strong>Object result = FuncApi.pingTask("id");
</strong></code></pre>

**Returns**

```
// Some code
```

## createTaskBySourceUid

Description...

```
FuncApi.createTaskBySourceUid(String taskName, String taskType, String sourceUid, String functionName, 
Map<String, Object> params)

or

FuncApi.createTaskBySourceUid(String taskName, String taskType,
 String sourceUid, String appName, String functionName, Map<String, Object> params)
```

#### Parameters

```
taskName
taskType
sourceUid
functionName
params
appName
```

**Sample Code**

<pre class="language-java"><code class="lang-java"><strong>Map&#x3C;String, Object> functionParameters = new LinkedHashMap&#x3C;String, Object>(); 
</strong><strong>Result result = FuncApi.createTaskBySourceUid("upsertTask", "CURD", "Job1123", "FUNCTION_NAME", functionParameters);
</strong><strong>
</strong></code></pre>

**Returns**

```
// Some code
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trillo.gitbook.io/trillo-workbench-java-sdk/serverless-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
