KapsoEx.Functions (kapso_ex v0.1.0)

Copy Markdown View Source

Functions: serverless JavaScript deployed by Kapso, invoked over the API or from workflows.

Summary

Functions

Creates a draft function (not deployed yet).

Creates a secret, exposed to the function as an environment variable.

Deletes a function, its deployment and its secrets.

Deploys a function in the background (usually 10-60 seconds). Poll get/2 for the status.

Gets a function with its code, deployment status and URLs.

Invokes a deployed function with payload as the request body. Returns the function's response (JSON decoded when it is JSON).

Lists the project's functions.

Lists recent invocations with captured console logs. Params: status, limit.

Lists secret names (never values).

Updates a function (partial). Attributes: name, slug, description, code, invoke_response_mode, runtime_config, public_endpoint, and lock_version for optimistic locking.

Types

result()

@type result() :: {:ok, term()} | {:error, KapsoEx.Error.t()}

Functions

create(client, attrs)

@spec create(KapsoEx.Client.t(), map() | keyword()) :: result()

Creates a draft function (not deployed yet).

Attributes: name, code and function_type ("cloudflare_worker" or "supabase_function") are required; also slug, description, public_endpoint, runtime_config.

create_secret(client, function_id, name, value)

@spec create_secret(KapsoEx.Client.t(), String.t(), String.t(), String.t() | map()) ::
  result()

Creates a secret, exposed to the function as an environment variable.

delete(client, function_id)

@spec delete(KapsoEx.Client.t(), String.t()) :: result()

Deletes a function, its deployment and its secrets.

delete_secret(client, function_id, name)

@spec delete_secret(KapsoEx.Client.t(), String.t(), String.t()) :: result()

Deletes a secret.

deploy(client, function_id)

@spec deploy(KapsoEx.Client.t(), String.t()) :: result()

Deploys a function in the background (usually 10-60 seconds). Poll get/2 for the status.

get(client, function_id)

@spec get(KapsoEx.Client.t(), String.t()) :: result()

Gets a function with its code, deployment status and URLs.

invoke(client, function_id, payload \\ %{})

@spec invoke(KapsoEx.Client.t(), String.t(), map() | list()) :: result()

Invokes a deployed function with payload as the request body. Returns the function's response (JSON decoded when it is JSON).

list(client)

@spec list(KapsoEx.Client.t()) :: result()

Lists the project's functions.

list_invocations(client, function_id, params \\ [])

@spec list_invocations(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()

Lists recent invocations with captured console logs. Params: status, limit.

list_secrets(client, function_id)

@spec list_secrets(KapsoEx.Client.t(), String.t()) :: result()

Lists secret names (never values).

update(client, function_id, attrs)

@spec update(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()

Updates a function (partial). Attributes: name, slug, description, code, invoke_response_mode, runtime_config, public_endpoint, and lock_version for optimistic locking.