Edge scripting — deploy and manage JavaScript/TypeScript code at the edge.
Uses the main API client created with Bunnyx.new/1.
Usage
client = Bunnyx.new(api_key: "sk-...")
{:ok, script} = Bunnyx.EdgeScript.create(client, name: "my-script", script_type: 1)
{:ok, nil} = Bunnyx.EdgeScript.set_code(client, script["Id"], "export default { fetch() {} }")
{:ok, scripts} = Bunnyx.EdgeScript.list(client)
Summary
Functions
Adds a secret to an edge script.
Adds a variable to an edge script. Returns the created variable with its ID.
Creates an edge script.
Deletes an edge script.
Deletes a secret from an edge script.
Deletes a variable from an edge script.
Fetches an edge script by ID.
Returns the active release for an edge script.
Returns the current code for an edge script.
Gets a variable by ID.
Lists edge scripts.
Lists published releases for an edge script.
Lists secrets for an edge script.
Publishes a release for an edge script.
Rotates the deployment key for an edge script.
Sets the code for an edge script.
Returns statistics for an edge script.
Updates an edge script.
Updates an existing secret.
Updates an existing variable.
Adds or updates a secret (upsert).
Adds or updates a variable (upsert).
Functions
@spec add_secret(Bunnyx.t() | keyword(), pos_integer(), String.t(), String.t()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Adds a secret to an edge script.
@spec add_variable(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Adds a variable to an edge script. Returns the created variable with its ID.
@spec create(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Creates an edge script.
Attributes
:name— script name (max 100 chars):script_type(required) — 0 = DNS, 1 = CDN, 2 = Middleware:code— initial code:create_linked_pull_zone— auto-create a linked pull zone:linked_pull_zone_name— name for the linked pull zone
@spec delete(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Deletes an edge script.
@spec delete_secret(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Deletes a secret from an edge script.
@spec delete_variable(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Deletes a variable from an edge script.
@spec get(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Fetches an edge script by ID.
@spec get_active_release(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Returns the active release for an edge script.
@spec get_code(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Returns the current code for an edge script.
@spec get_variable(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Gets a variable by ID.
@spec list( Bunnyx.t() | keyword(), keyword() ) :: {:ok, %{ items: [map()], current_page: integer(), total_items: integer(), has_more_items: boolean() }} | {:error, Bunnyx.Error.t()}
Lists edge scripts.
Options
:page— page number:per_page— items per page:search— search term:type— filter by script type (0 = DNS, 1 = CDN, 2 = Middleware)
@spec list_releases(Bunnyx.t() | keyword(), pos_integer(), keyword()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Lists published releases for an edge script.
@spec list_secrets(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, list()} | {:error, Bunnyx.Error.t()}
Lists secrets for an edge script.
@spec publish_release(Bunnyx.t() | keyword(), pos_integer(), keyword()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Publishes a release for an edge script.
Options
:note— release note:uuid— specific release UUID to publish
@spec rotate_deployment_key(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Rotates the deployment key for an edge script.
@spec set_code(Bunnyx.t() | keyword(), pos_integer(), String.t()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Sets the code for an edge script.
@spec statistics(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Returns statistics for an edge script.
@spec update(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}
Updates an edge script.
@spec update_secret(Bunnyx.t() | keyword(), pos_integer(), String.t(), String.t()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Updates an existing secret.
@spec update_variable( Bunnyx.t() | keyword(), pos_integer(), pos_integer(), Bunnyx.Params.attrs() ) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Updates an existing variable.
@spec upsert_secret(Bunnyx.t() | keyword(), pos_integer(), String.t(), String.t()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Adds or updates a secret (upsert).
@spec upsert_variable(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Adds or updates a variable (upsert).