View Source Appwrite.Services.Functions (appwrite v0.2.1)

The Functions service allows you to create custom behaviour that can be triggered by any supported Appwrite system events or by a predefined schedule.

Appwrite Cloud Functions lets you automatically run backend code in response to events triggered by Appwrite or by setting it to be executed in a predefined schedule. Your code is stored in a secure way on your Appwrite instance and is executed in an isolated environment.

Summary

Functions

create_execution(function_id, body \\ nil, async \\ nil, xpath \\ nil, method \\ nil, headers \\ nil, scheduled_at \\ nil)

@spec create_execution(
  String.t(),
  String.t() | nil,
  boolean() | nil,
  String.t() | nil,
  String.t() | nil,
  map() | nil,
  String.t() | nil
) :: {:ok, Appwrite.Types.Execution.t()} | {:error, any()}

Create a function execution.

Parameters

  • function_id (String.t()): The function ID.
  • body (String.t() | nil): Optional execution request body.

  • async (boolean() | nil): Whether to execute asynchronously.

  • xpath (String.t() | nil): Optional execution path override.

  • method (String.t() | nil): Optional HTTP method override. Must be a valid ExecutionMethod value.

  • headers (map() | nil): Optional custom HTTP headers.

  • scheduled_at (String.t() | nil): Optional ISO 8601 scheduled execution time.

Returns

  • {:ok, Execution.t()} on success.
  • {:error, reason} on failure.

get_execution(function_id, execution_id)

@spec get_execution(String.t(), String.t()) ::
  {:ok, Appwrite.Types.Execution.t()} | {:error, any()}

Fetch a specific function execution by its ID.

Parameters

  • function_id (String.t()): The function ID.
  • execution_id (String.t()): The execution ID.

Returns

  • {:ok, Execution.t()} on success.
  • {:error, reason} on failure.

list_executions(function_id, queries \\ nil, search \\ nil)

@spec list_executions(String.t(), [String.t()] | nil, String.t() | nil) ::
  {:ok, Appwrite.Types.ExecutionList.t()} | {:error, any()}

List all executions for a given function.

Parameters

  • function_id (String.t()): The function ID.
  • queries ([String.t()] | nil): Optional query parameters.

  • search (String.t() | nil): Optional search keyword.

Returns

  • {:ok, ExecutionList.t()} on success.
  • {:error, reason} on failure.