Packages
lexdee
2.3.2
2.6.4
2.6.3
2.6.2
2.6.1
2.6.0
2.5.1
2.5.0
2.4.5
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.11
2.3.10
2.3.9
2.3.8
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.0
2.2.7
2.2.6
2.2.5
2.2.3
2.2.2
2.2.1
2.2.0
2.1.1
2.0.2
2.0.1
2.0.0
1.0.6
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
Client library for LXD
Current section
Files
Jump to
Current section
Files
lib/lexdee/instances/state.ex
defmodule Lexdee.Instances.State do
alias Lexdee.Instances
@path "/state"
@spec show(Tesla.Client.t(), binary) :: {:error, any} | {:ok, Tesla.Env.t()}
def show(client, id), do: Tesla.get(client, Path.join(id, @path))
@spec start(Tesla.Client.t(), binary, Keyword.t()) ::
{:error, any} | {:ok, Tesla.Env.t()}
def start(client, id, options \\ []),
do: execute(client, id, %{"action" => "start"}, options)
@spec stop(Tesla.Client.t(), binary, Keyword.t()) ::
{:error, any} | {:ok, Tesla.Env.t()}
def stop(client, id, options \\ []),
do: execute(client, id, %{"action" => "stop"}, options)
@spec restart(Tesla.Client.t(), binary, Keyword.t()) ::
{:error, any} | {:ok, Tesla.Env.t()}
def restart(client, id, options \\ []),
do: execute(client, id, %{"action" => "restart"}, options)
defp execute(client, id, base_params, options) do
params =
Map.merge(base_params, %{
"timeout" => Keyword.get(options, :timeout, 30),
"force" => Keyword.get(options, :force, false),
"stateful" => Keyword.get(options, :stateful, false)
})
Tesla.put(
client,
Path.join([Instances.base_path(), id, @path]),
params,
options
)
end
end