Storage zones are the containers that hold files served through bunny.net's edge storage network. This module manages storage zones through the main API — creating, configuring, and deleting them.
This is separate from Bunnyx.Storage, which handles file operations (upload,
download) within a storage zone using a different authentication method.
Uses the main API client created with Bunnyx.new/1.
Usage
client = Bunnyx.new(api_key: "sk-...")
{:ok, zone} = Bunnyx.StorageZone.create(client,
name: "my-zone",
region: "DE"
)
{:ok, zone} = Bunnyx.StorageZone.get(client, zone.id)
{:ok, page} = Bunnyx.StorageZone.list(client)
{:ok, zone} = Bunnyx.StorageZone.update(client, zone.id, rewrite_404_to_200: true)
{:ok, nil} = Bunnyx.StorageZone.delete(client, zone.id)
Summary
Functions
Checks if a storage zone name is available.
Creates a storage zone with the given attributes.
Deletes a storage zone.
Fetches a storage zone by ID.
Lists storage zones.
Resets the storage zone password.
Resets the storage zone read-only password.
Returns storage zone statistics.
Updates a storage zone.
Types
@type t() :: %Bunnyx.StorageZone{ custom_404_file_path: String.t() | nil, date_modified: String.t() | nil, deleted: boolean() | nil, files_stored: integer() | nil, id: pos_integer() | nil, name: String.t() | nil, password: String.t() | nil, read_only_password: String.t() | nil, region: String.t() | nil, replication_regions: [String.t()] | nil, rewrite_404_to_200: boolean() | nil, storage_hostname: String.t() | nil, storage_used: integer() | nil, zone_tier: integer() | nil }
Functions
@spec check_availability(Bunnyx.t() | keyword(), String.t()) :: {:ok, boolean()} | {:error, Bunnyx.Error.t()}
Checks if a storage zone name is available.
@spec create(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) :: {:ok, t()} | {:error, Bunnyx.Error.t()}
Creates a storage zone with the given attributes.
@spec delete(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Deletes a storage zone.
@spec get(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, t()} | {:error, Bunnyx.Error.t()}
Fetches a storage zone by ID.
@spec list( Bunnyx.t() | keyword(), keyword() ) :: {:ok, [t()] | %{ items: [t()], current_page: integer(), total_items: integer(), has_more_items: boolean() }} | {:error, Bunnyx.Error.t()}
Lists storage zones.
Options
:page— page number:per_page— items per page:search— search term:include_deleted— include deleted zones
@spec reset_password(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Resets the storage zone password.
@spec reset_read_only_password(Bunnyx.t() | keyword(), pos_integer()) :: {:ok, nil} | {:error, Bunnyx.Error.t()}
Resets the storage zone read-only password.
@spec statistics(Bunnyx.t() | keyword(), pos_integer(), keyword()) :: {:ok, %{storage_used_chart: map(), file_count_chart: map()}} | {:error, Bunnyx.Error.t()}
Returns storage zone statistics.
Options
:date_from— start date (ISO 8601 string):date_to— end date (ISO 8601 string)
@spec update(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) :: {:ok, t()} | {:error, Bunnyx.Error.t()}
Updates a storage zone.