NomadClient.Api.Client (nomad_client v0.12.4)

API calls for all endpoints tagged Client.

Link to this section Summary

Functions

forces a garbage collection of a particular, stopped allocation on a node

forces a garbage collection of all stopped allocations on a node

query the actual resources consumed by an allocation

reads the contents of a file in an allocation directory

reads the contents of a file in an allocation directory at a particular offset and limit

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

lists files in an allocation directory

streams the contents of a file in an allocation directory

Link to this section Functions

Link to this function

garbage_collect_allocation(connection, alloc_id, opts \\ [])

Specs

garbage_collect_allocation(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, nil} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

garbage_collect_allocation_0(connection, opts \\ [])

Specs

garbage_collect_allocation_0(Tesla.Env.client(), keyword()) ::
  {:ok, nil} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

get_client_allocation_stats(connection, alloc_id, opts \\ [])

Specs

get_client_allocation_stats(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, NomadClient.Model.AllocResourceUsage.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

get_client_file(connection, alloc_id, opts \\ [])

Specs

get_client_file(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

get_client_file_at_offest(connection, alloc_id, offset, limit, opts \\ [])

Specs

get_client_file_at_offest(
  Tesla.Env.client(),
  String.t(),
  integer(),
  integer(),
  keyword()
) :: {:ok, String.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

get_client_stats(connection, opts \\ [])

Specs

get_client_stats(Tesla.Env.client(), keyword()) ::
  {:ok, [NomadClient.Model.HostStats.t()]} | {:error, Tesla.Env.t()}

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

, ...]} on success {:error, Tesla.Env.t} on failure

Link to this function

list_client_files(connection, alloc_id, opts \\ [])

Specs

list_client_files(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, [NomadClient.Model.AllocFileInfo.t()]} | {:error, Tesla.Env.t()}

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

, ...]} on success {:error, Tesla.Env.t} on failure

Link to this function

stat_client_file(connection, alloc_id, opts \\ [])

Specs

stat_client_file(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, NomadClient.Model.AllocFileInfo.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

stream_client_file(connection, alloc_id, offset, opts \\ [])

Specs

stream_client_file(Tesla.Env.client(), String.t(), integer(), keyword()) ::
  {:ok, String.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure

Link to this function

stream_client_logs(connection, alloc_id, task, offset, opts \\ [])

Specs

stream_client_logs(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  integer(),
  keyword()
) :: {:ok, String.t()} | {:error, Tesla.Env.t()}

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

on success {:error, Tesla.Env.t} on failure