Packages

The Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API.

Current section

Files

Jump to
ex_docker_engine_api lib docker_engine_api api network.ex
Raw

lib/docker_engine_api/api/network.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.0.1 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule DockerEngineAPI.Api.Network do
@moduledoc """
API calls for all endpoints tagged `Network`.
"""
alias DockerEngineAPI.Connection
import DockerEngineAPI.RequestBuilder
@doc """
Connect a container to a network
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `id` (String.t): Network ID or name
- `container` (NetworkConnectRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_connect(Tesla.Env.client, String.t, DockerEngineAPI.Model.NetworkConnectRequest.t, keyword()) :: {:ok, nil} | {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def network_connect(connection, id, container, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/networks/#{id}/connect")
|> add_param(:body, :body, container)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false},
{403, DockerEngineAPI.Model.ErrorResponse},
{404, DockerEngineAPI.Model.ErrorResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
Create a network
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `network_config` (NetworkCreateRequest): Network configuration
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, DockerEngineAPI.Model.NetworkCreateResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_create(Tesla.Env.client, DockerEngineAPI.Model.NetworkCreateRequest.t, keyword()) :: {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:ok, DockerEngineAPI.Model.NetworkCreateResponse.t} | {:error, Tesla.Env.t}
def network_create(connection, network_config, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/networks/create")
|> add_param(:body, :body, network_config)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, DockerEngineAPI.Model.NetworkCreateResponse},
{403, DockerEngineAPI.Model.ErrorResponse},
{404, DockerEngineAPI.Model.ErrorResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
Remove a network
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `id` (String.t): Network ID or name
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_delete(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def network_delete(connection, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/networks/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{403, DockerEngineAPI.Model.ErrorResponse},
{404, DockerEngineAPI.Model.ErrorResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
Disconnect a container from a network
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `id` (String.t): Network ID or name
- `container` (NetworkDisconnectRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_disconnect(Tesla.Env.client, String.t, DockerEngineAPI.Model.NetworkDisconnectRequest.t, keyword()) :: {:ok, nil} | {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def network_disconnect(connection, id, container, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/networks/#{id}/disconnect")
|> add_param(:body, :body, container)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false},
{403, DockerEngineAPI.Model.ErrorResponse},
{404, DockerEngineAPI.Model.ErrorResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
Inspect a network
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `id` (String.t): Network ID or name
- `opts` (keyword): Optional parameters
- `:verbose` (boolean()): Detailed inspect output for troubleshooting
- `:scope` (String.t): Filter the network by scope (swarm, global, or local)
### Returns
- `{:ok, DockerEngineAPI.Model.Network.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_inspect(Tesla.Env.client, String.t, keyword()) :: {:ok, DockerEngineAPI.Model.Network.t} | {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def network_inspect(connection, id, opts \\ []) do
optional_params = %{
:verbose => :query,
:scope => :query
}
request =
%{}
|> method(:get)
|> url("/networks/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, DockerEngineAPI.Model.Network},
{404, DockerEngineAPI.Model.ErrorResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
List networks
Returns a list of networks. For details on the format, see the [network inspect endpoint](#operation/NetworkInspect). Note that it uses a different, smaller representation of a network than inspecting a single network. For example, the list of containers attached to the network is not propagated in API versions 1.28 and up.
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:filters` (String.t): JSON encoded value of the filters (a `map[string][]string`) to process on the networks list. Available filters: - `dangling=<boolean>` When set to `true` (or `1`), returns all networks that are not in use by a container. When set to `false` (or `0`), only networks that are in use by one or more containers are returned. - `driver=<driver-name>` Matches a network's driver. - `id=<network-id>` Matches all or part of a network ID. - `label=<key>` or `label=<key>=<value>` of a network label. - `name=<network-name>` Matches all or part of a network name. - `scope=[\"swarm\"|\"global\"|\"local\"]` Filters networks by scope (`swarm`, `global`, or `local`). - `type=[\"custom\"|\"builtin\"]` Filters networks by type. The `custom` keyword returns all user-defined networks.
### Returns
- `{:ok, [%Network{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_list(Tesla.Env.client, keyword()) :: {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:ok, list(DockerEngineAPI.Model.Network.t)} | {:error, Tesla.Env.t}
def network_list(connection, opts \\ []) do
optional_params = %{
:filters => :query
}
request =
%{}
|> method(:get)
|> url("/networks")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, DockerEngineAPI.Model.Network},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
@doc """
Delete unused networks
### Parameters
- `connection` (DockerEngineAPI.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:filters` (String.t): Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters: - `until=<timestamp>` Prune networks created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune networks with (or without, in case `label!=...` is used) the specified labels.
### Returns
- `{:ok, DockerEngineAPI.Model.NetworkPruneResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec network_prune(Tesla.Env.client, keyword()) :: {:ok, DockerEngineAPI.Model.ErrorResponse.t} | {:ok, DockerEngineAPI.Model.NetworkPruneResponse.t} | {:error, Tesla.Env.t}
def network_prune(connection, opts \\ []) do
optional_params = %{
:filters => :query
}
request =
%{}
|> method(:post)
|> url("/networks/prune")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, DockerEngineAPI.Model.NetworkPruneResponse},
{500, DockerEngineAPI.Model.ErrorResponse}
])
end
end