# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # https://openapi-generator.tech # Do not edit the class manually. defmodule Nomad.Api.Allocations do @moduledoc """ API calls for all endpoints tagged `Allocations`. """ alias Nomad.Connection import Nomad.RequestBuilder @doc """ reads information about a specific allocation ## Parameters - connection (Nomad.Connection): Connection to server - alloc_id (String.t): Specifies the UUID of the allocation. This must be the full UUID, not the short 8-character one - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, Nomad.Model.Allocation.t} on success {:error, Tesla.Env.t} on failure """ @spec get_allocation(Tesla.Env.client(), String.t(), keyword()) :: {:ok, Nomad.Model.Allocation.t()} | {:error, Tesla.Env.t()} def get_allocation(connection, alloc_id, _opts \\ []) do %{} |> method(:get) |> url("/allocation/#{alloc_id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ {200, %Nomad.Model.Allocation{}} ]) end @doc """ query for and interact with allocations ## Parameters - connection (Nomad.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :prefix (String.t): Specifies a string to filter jobs on based on an index prefix. This is specified as a query string parameter ## Returns {:ok, [%AllocationListStub{}, ...]} on success {:error, Tesla.Env.t} on failure """ @spec get_allocations(Tesla.Env.client(), keyword()) :: {:ok, list(Nomad.Model.AllocationListStub.t())} | {:error, Tesla.Env.t()} def get_allocations(connection, opts \\ []) do optional_params = %{ :prefix => :query } %{} |> method(:get) |> url("/allocations") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ {200, [%Nomad.Model.AllocationListStub{}]} ]) end @doc """ restarts an allocation or task in-place ## Parameters - connection (Nomad.Connection): Connection to server - alloc_id (String.t): Specifies the UUID of the allocation. This must be the full UUID, not the short 8-character one - opts (KeywordList): [optional] Optional parameters - :body (AllocationRestartRequest): ## Returns {:ok, nil} on success {:error, Tesla.Env.t} on failure """ @spec restart_allocation(Tesla.Env.client(), String.t(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()} def restart_allocation(connection, alloc_id, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/allocation/#{alloc_id}/restart") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ {200, false} ]) end @doc """ sends a signal to an allocation or task ## Parameters - connection (Nomad.Connection): Connection to server - alloc_id (String.t): Specifies the UUID of the allocation. This must be the full UUID, not the short 8-character one - opts (KeywordList): [optional] Optional parameters - :body (AllocSignalRequest): ## Returns {:ok, nil} on success {:error, Tesla.Env.t} on failure """ @spec signal_allocation(Tesla.Env.client(), String.t(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()} def signal_allocation(connection, alloc_id, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/allocation/#{alloc_id}/signal") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ {200, false} ]) end @doc """ stops and reschedules a specific allocation ## Parameters - connection (Nomad.Connection): Connection to server - alloc_id (String.t): Specifies the UUID of the allocation. This must be the full UUID, not the short 8-character one - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, Nomad.Model.AllocStopResponse.t} on success {:error, Tesla.Env.t} on failure """ @spec stop_allocation(Tesla.Env.client(), String.t(), keyword()) :: {:ok, Nomad.Model.AllocStopResponse.t()} | {:error, Tesla.Env.t()} def stop_allocation(connection, alloc_id, _opts \\ []) do %{} |> method(:post) |> url("/allocation/#{alloc_id}/stop") |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ {200, %Nomad.Model.AllocStopResponse{}} ]) end end