# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.
defmodule NomadClient.Api.Client do
@moduledoc """
API calls for all endpoints tagged `Client`.
"""
alias NomadClient.Connection
import NomadClient.RequestBuilder
@doc """
forces a garbage collection of a particular, stopped allocation on a node
## Parameters
- connection (NomadClient.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
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
## Returns
{:ok, nil} on success
{:error, Tesla.Env.t} on failure
"""
@spec garbage_collect_allocation(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def garbage_collect_allocation(connection, alloc_id, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query
}
%{}
|> method(:get)
|> url("/client/allocation/#{alloc_id}/gc")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
forces a garbage collection of all stopped allocations on a node
## Parameters
- connection (NomadClient.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :node_id (String.t): node id
## Returns
{:ok, nil} on success
{:error, Tesla.Env.t} on failure
"""
@spec garbage_collect_allocation_0(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def garbage_collect_allocation_0(connection, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:node_id => :query
}
%{}
|> method(:get)
|> url("/client/gc")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
query the actual resources consumed by an allocation
## Parameters
- connection (NomadClient.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
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
## Returns
{:ok, NomadClient.Model.AllocResourceUsage.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_client_allocation_stats(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, NomadClient.Model.AllocResourceUsage.t()} | {:error, Tesla.Env.t()}
def get_client_allocation_stats(connection, alloc_id, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query
}
%{}
|> method(:get)
|> url("/client/allocation/#{alloc_id}/stats")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %NomadClient.Model.AllocResourceUsage{}}
])
end
@doc """
reads the contents of a file in an allocation directory
## Parameters
- connection (NomadClient.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
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :path (String.t): Specifies the path of the file to read, relative to the root of the allocation directory
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_client_file(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def get_client_file(connection, alloc_id, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:path => :query
}
%{}
|> method(:get)
|> url("/client/fs/cat/#{alloc_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
reads the contents of a file in an allocation directory at a particular offset and limit
## Parameters
- connection (NomadClient.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
- offset (integer()): Specifies the byte offset from where content will be read
- limit (integer()): Specifies the number of bytes to read from the offset
- opts (KeywordList): [optional] Optional parameters
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :path (String.t): Specifies the path of the file to read, relative to the root of the allocation directory
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_client_file_at_offest(Tesla.Env.client(), String.t(), integer(), integer(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def get_client_file_at_offest(connection, alloc_id, offset, limit, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:path => :query
}
%{}
|> method(:get)
|> url("/client/fs/readat/#{alloc_id}")
|> add_param(:query, :offset, offset)
|> add_param(:query, :limit, limit)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
queries the actual resources consumed on a node. The API endpoint is hosted by the Nomad client and requests have to be made to the nomad client whose resource usage metrics are of interest
## Parameters
- connection (NomadClient.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :node_id (String.t): node id
## Returns
{:ok, [%HostStats{}, ...]} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_client_stats(Tesla.Env.client(), keyword()) ::
{:ok, list(NomadClient.Model.HostStats.t())} | {:error, Tesla.Env.t()}
def get_client_stats(connection, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:node_id => :query
}
%{}
|> method(:get)
|> url("/client/stats")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, [%NomadClient.Model.HostStats{}]}
])
end
@doc """
lists files in an allocation directory
## Parameters
- connection (NomadClient.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
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :path (String.t): Specifies the path of the file to read, relative to the root of the allocation directory
## Returns
{:ok, [%AllocFileInfo{}, ...]} on success
{:error, Tesla.Env.t} on failure
"""
@spec list_client_files(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, list(NomadClient.Model.AllocFileInfo.t())} | {:error, Tesla.Env.t()}
def list_client_files(connection, alloc_id, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:path => :query
}
%{}
|> method(:get)
|> url("/client/fs/ls/#{alloc_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, [%NomadClient.Model.AllocFileInfo{}]}
])
end
@doc """
stats a file in an allocation
## Parameters
- connection (NomadClient.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
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :path (String.t): Specifies the path of the file to read, relative to the root of the allocation directory
## Returns
{:ok, NomadClient.Model.AllocFileInfo.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec stat_client_file(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, NomadClient.Model.AllocFileInfo.t()} | {:error, Tesla.Env.t()}
def stat_client_file(connection, alloc_id, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:path => :query
}
%{}
|> method(:get)
|> url("/client/fs/stat/#{alloc_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %NomadClient.Model.AllocFileInfo{}}
])
end
@doc """
streams the contents of a file in an allocation directory
## Parameters
- connection (NomadClient.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
- offset (integer()): Specifies the byte offset from where content will be read
- opts (KeywordList): [optional] Optional parameters
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :path (String.t): Specifies the path of the file to read, relative to the root of the allocation directory
- :follow (boolean()): Specifies whether to tail the file
- :origin (String.t): Applies the relative offset to either the start or end of the file
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec stream_client_file(Tesla.Env.client(), String.t(), integer(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def stream_client_file(connection, alloc_id, offset, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:path => :query,
:follow => :query,
:origin => :query
}
%{}
|> method(:get)
|> url("/client/fs/stream/#{alloc_id}")
|> add_param(:query, :offset, offset)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
streams a task's stderr/stdout logs
## Parameters
- connection (NomadClient.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
- task (String.t): Specifies the name of the task inside the allocation to stream logs from
- offset (integer()): Specifies the byte offset from where content will be read
- opts (KeywordList): [optional] Optional parameters
- :namespace (String.t):
- :region (String.t): Make a request across regions to the given region
- :index (integer()): index used for blocking requests
- :wait (String.t): wait time used for blocking requests
- :follow (boolean()): Specifies whether to tail the file
- :type (String.t): Specifies the stream to stream
- :origin (String.t): Applies the relative offset to either the start or end of the file
- :plain (boolean()): is plain text format
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec stream_client_logs(Tesla.Env.client(), String.t(), String.t(), integer(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def stream_client_logs(connection, alloc_id, task, offset, opts \\ []) do
optional_params = %{
:namespace => :query,
:region => :query,
:index => :query,
:wait => :query,
:follow => :query,
:type => :query,
:origin => :query,
:plain => :query
}
%{}
|> method(:get)
|> url("/client/fs/logs/#{alloc_id}")
|> add_param(:query, :task, task)
|> add_param(:query, :offset, offset)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
end