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

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()}

Creates a function execution.

Parameters

  • function_id (String.t()): The function ID.
  • body (String.t()): Optional execution body.
  • async (boolean()): Optional async flag.
  • xpath (String.t()): Optional execution path.
  • method (String.t()): Optional HTTP method.
  • headers (map()): Optional HTTP headers.
  • scheduled_at (String.t()): Optional scheduled time.

Returns

  • {:ok, %Execution{}} 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()}

Fetches 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{}} 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()}

Lists all executions for a given function.

Parameters

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

Returns

  • {:ok, %ExecutionList{}} on success.
  • {:error, reason} on failure.