Bunnyx.MagicContainers (Bunnyx v0.4.0)

Copy Markdown View Source

Magic Containers — deploy and manage containerized applications at bunny.net's edge.

Uses the main API client created with Bunnyx.new/1. All endpoints are under /mc/.

Usage

client = Bunnyx.new(api_key: "sk-...")

{:ok, app} = Bunnyx.MagicContainers.create(client,
  name: "my-app",
  runtime_type: "Shared",
  auto_scaling: %{"minReplicas" => 1, "maxReplicas" => 3},
  region_settings: %{"baseRegion" => "DE"}
)

{:ok, nil} = Bunnyx.MagicContainers.deploy(client, app.id)
{:ok, apps} = Bunnyx.MagicContainers.list(client)

Summary

Functions

Adds a container template to an application.

Adds an endpoint to a container.

Adds a container registry.

Creates an application.

Creates a log forwarding configuration.

Deletes an application.

Deletes all instances of a volume.

Deletes a container template.

Deletes a log forwarding configuration.

Deletes a container registry.

Deploys an application.

Detaches a volume from its container.

Fetches an application by ID.

Gets autoscaling settings for an application.

Gets container config suggestions for an image.

Gets a container template.

Gets the digest for a container image.

Gets resource limits and usage for the authenticated user.

Gets a log forwarding configuration.

Gets the optimal base region based on CDN server token.

Gets region settings for an application.

Gets a container registry by ID.

Lists applications.

Lists endpoints for all containers in an application.

Lists tags for a container image.

Lists container images in a private registry.

Lists log forwarding configurations.

Lists all node IP addresses in the Magic Containers network.

Lists all available deployment regions.

Lists all container registries.

Lists volumes for an application.

Returns an overview for an application.

Partially updates an application (JSON Merge Patch).

Recreates a pod (deletes and re-creates it).

Restarts all pods for an application.

Searches for public container images.

Replaces all environment variables for a container template.

Returns statistics for an application.

Undeploys an application (stops all running instances).

Replaces the full application configuration.

Updates autoscaling settings for an application.

Updates a log forwarding configuration.

Updates region settings for an application.

Updates a container registry.

Functions

add_container(client, app_id, config)

@spec add_container(Bunnyx.t() | keyword(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Adds a container template to an application.

add_endpoint(client, app_id, container_id, config)

@spec add_endpoint(Bunnyx.t() | keyword(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Adds an endpoint to a container.

add_registry(client, config)

@spec add_registry(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Adds a container registry.

create(client, attrs)

@spec create(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) ::
  {:ok, Bunnyx.MagicContainers.App.t()} | {:error, Bunnyx.Error.t()}

Creates an application.

Attributes

  • :name (required) — app name
  • :runtime_type (required) — "Shared" or "Reserved"
  • :auto_scaling — autoscaling config map (camelCase keys)
  • :region_settings — region config map (camelCase keys)
  • :container_templates — list of container config maps
  • :volumes — list of volume config maps

create_log_forwarding(client, config)

@spec create_log_forwarding(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Creates a log forwarding configuration.

delete(client, app_id)

@spec delete(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes an application.

delete_all_volume_instances(client, app_id, volume_id)

@spec delete_all_volume_instances(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes all instances of a volume.

delete_container(client, app_id, container_id)

@spec delete_container(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a container template.

delete_endpoint(client, app_id, endpoint_id)

@spec delete_endpoint(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes an endpoint.

delete_log_forwarding(client, config_id)

@spec delete_log_forwarding(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a log forwarding configuration.

delete_registry(client, registry_id)

@spec delete_registry(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a container registry.

delete_volume_instance(client, app_id, volume_id, instance_id)

@spec delete_volume_instance(
  Bunnyx.t() | keyword(),
  String.t(),
  String.t(),
  String.t()
) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a specific volume instance.

deploy(client, app_id)

@spec deploy(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deploys an application.

detach_volume(client, app_id, volume_id)

@spec detach_volume(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Detaches a volume from its container.

get(client, app_id)

@spec get(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, Bunnyx.MagicContainers.App.t()} | {:error, Bunnyx.Error.t()}

Fetches an application by ID.

get_autoscaling(client, app_id)

@spec get_autoscaling(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets autoscaling settings for an application.

get_config_suggestions(client, body)

@spec get_config_suggestions(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets container config suggestions for an image.

get_container(client, app_id, container_id)

@spec get_container(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets a container template.

get_image_digest(client, body)

@spec get_image_digest(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the digest for a container image.

get_limits(client)

@spec get_limits(Bunnyx.t() | keyword()) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets resource limits and usage for the authenticated user.

get_log_forwarding(client, config_id)

@spec get_log_forwarding(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets a log forwarding configuration.

get_optimal_region(client, cdn_server_token)

@spec get_optimal_region(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the optimal base region based on CDN server token.

get_region_settings(client, app_id)

@spec get_region_settings(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets region settings for an application.

get_registry(client, registry_id)

@spec get_registry(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets a container registry by ID.

list(client, opts \\ [])

@spec list(
  Bunnyx.t() | keyword(),
  keyword()
) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists applications.

Options

  • :per_page — results per page (1–1000, default 20)
  • :next_cursor — pagination cursor

list_endpoints(client, app_id)

@spec list_endpoints(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists endpoints for all containers in an application.

list_image_tags(client, body)

@spec list_image_tags(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists tags for a container image.

list_images(client, body)

@spec list_images(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists container images in a private registry.

list_log_forwarding(client)

@spec list_log_forwarding(Bunnyx.t() | keyword()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists log forwarding configurations.

list_nodes(client, opts \\ [])

@spec list_nodes(
  Bunnyx.t() | keyword(),
  keyword()
) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists all node IP addresses in the Magic Containers network.

list_regions(client)

@spec list_regions(Bunnyx.t() | keyword()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists all available deployment regions.

list_registries(client)

@spec list_registries(Bunnyx.t() | keyword()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists all container registries.

list_volumes(client, app_id)

@spec list_volumes(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists volumes for an application.

overview(client, app_id)

@spec overview(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns an overview for an application.

patch(client, app_id, changes)

@spec patch(Bunnyx.t() | keyword(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Partially updates an application (JSON Merge Patch).

patch_container(client, app_id, container_id, changes)

@spec patch_container(Bunnyx.t() | keyword(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Patches a container template.

recreate_pod(client, app_id, pod_id)

@spec recreate_pod(Bunnyx.t() | keyword(), String.t(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Recreates a pod (deletes and re-creates it).

restart(client, app_id)

@spec restart(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Restarts all pods for an application.

search_public_images(client, body)

@spec search_public_images(Bunnyx.t() | keyword(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Searches for public container images.

set_container_env(client, app_id, container_id, env_vars)

@spec set_container_env(Bunnyx.t() | keyword(), String.t(), String.t(), list()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Replaces all environment variables for a container template.

statistics(client, app_id)

@spec statistics(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns statistics for an application.

undeploy(client, app_id)

@spec undeploy(Bunnyx.t() | keyword(), String.t()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Undeploys an application (stops all running instances).

update(client, app_id, attrs)

@spec update(Bunnyx.t() | keyword(), String.t(), Bunnyx.Params.attrs()) ::
  {:ok, Bunnyx.MagicContainers.App.t()} | {:error, Bunnyx.Error.t()}

Replaces the full application configuration.

update_autoscaling(client, app_id, config)

@spec update_autoscaling(Bunnyx.t() | keyword(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates autoscaling settings for an application.

update_endpoint(client, app_id, endpoint_id, config)

@spec update_endpoint(Bunnyx.t() | keyword(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates an endpoint.

update_log_forwarding(client, config_id, config)

@spec update_log_forwarding(Bunnyx.t() | keyword(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a log forwarding configuration.

update_region_settings(client, app_id, config)

@spec update_region_settings(Bunnyx.t() | keyword(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates region settings for an application.

update_registry(client, registry_id, config)

@spec update_registry(Bunnyx.t() | keyword(), pos_integer(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a container registry.

update_volume(client, app_id, volume_id, config)

@spec update_volume(Bunnyx.t() | keyword(), String.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a volume.