# `Testcontainers.ToxiproxyContainer`
[🔗](https://github.com/testcontainers/testcontainers-elixir/blob/main/lib/container/toxiproxy_container.ex#L2)

Provides functionality for creating and managing Toxiproxy container configurations.

Toxiproxy is a framework for simulating network conditions. It's made specifically
to work in testing, CI and development environments, supporting deterministic tampering
with connections, but with support for randomized chaos and customization.

# `api_url`

Returns the URI for the Toxiproxy API.

This can be used with ToxiproxyEx:

    ToxiproxyContainer.api_url(container)
    |> then(&Application.put_env(:toxiproxy_ex, :host, &1))

# `configure_toxiproxy_ex`

Configures the ToxiproxyEx library to use this container.

This sets the `:toxiproxy_ex` application environment to point to
the running container's API endpoint.

## Example

    {:ok, toxiproxy} = Testcontainers.start_container(ToxiproxyContainer.new())
    :ok = ToxiproxyContainer.configure_toxiproxy_ex(toxiproxy)

    # Now ToxiproxyEx will use this container
    ToxiproxyEx.get!("my_proxy") |> ToxiproxyEx.down!(fn -> ... end)

# `control_port`

Returns the control port number (for the Toxiproxy HTTP API).

# `create_proxy`

Creates a proxy in Toxiproxy that routes traffic from a container port to an upstream service.

## Parameters

- `container` - The running Toxiproxy container
- `name` - A unique name for the proxy
- `upstream` - The upstream address in format "host:port" (as seen from Toxiproxy container)
- `opts` - Optional keyword list:
  - `:listen_port` - Specific port to listen on (default: auto-allocated from 8666+)

# `create_proxy_for_container`

Creates a proxy for another container on the same network.

This is a convenience function that creates a proxy using the target container's
hostname and port.

## Parameters

- `toxiproxy` - The running Toxiproxy container
- `name` - A unique name for the proxy
- `target_container` - The target container to proxy to
- `target_port` - The port on the target container
- `opts` - Optional keyword list (see `create_proxy/4`)

# `default_image`

Retrieves the default Docker image for the Toxiproxy container.

# `delete_proxy`

Deletes a proxy from Toxiproxy.

# `first_proxy_port`

Returns the first proxy port number.

# `list_proxies`

Lists all proxies configured in Toxiproxy.

Returns a map of proxy names to their configurations.

# `mapped_control_port`

Returns the mapped control port on the host for the running container.

# `new`

Creates a new `ToxiproxyContainer` struct with default configurations.

# `proxy_port_count`

Returns the number of proxy ports reserved.

# `reset`

Resets Toxiproxy, removing all toxics and re-enabling all proxies.

# `with_image`

Overrides the default image used for the Toxiproxy container.

# `with_reuse`

Set the reuse flag to reuse the container if it is already running.

# `with_wait_timeout`

Overrides the default wait timeout used for the Toxiproxy container.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
