# NOTE: This file is auto generated by OpenAPI Generator 6.2.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule NomadClient.Api.Jobs do
@moduledoc """
API calls for all endpoints tagged `Jobs`.
"""
alias NomadClient.Connection
import NomadClient.RequestBuilder
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
- `:purge` (boolean()): Boolean flag indicating whether to purge allocations of the job after deleting.
- `:global` (boolean()): Boolean flag indicating whether the operation should apply to all instances of the job globally.
### Returns
- `{:ok, NomadClient.Model.JobDeregisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_job(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, NomadClient.Model.JobDeregisterResponse.t()}
| {:error, Tesla.Env.t()}
def delete_job(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query,
:purge => :query,
:global => :query
}
request =
%{}
|> method(:delete)
|> url("/job/#{job_name}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobDeregisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, NomadClient.Model.Job.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.Job.t()} | {:error, Tesla.Env.t()}
def get_job(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.Job{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
- `:all` (boolean()): Specifies whether the list of allocations should include allocations from a previously registered job with the same ID. This is possible if the job is deregistered and reregistered.
### Returns
- `{:ok, [%AllocationListStub{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_allocations(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, list(NomadClient.Model.AllocationListStub.t())}
| {:error, Tesla.Env.t()}
def get_job_allocations(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query,
:all => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/allocations")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, [%NomadClient.Model.AllocationListStub{}]},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, NomadClient.Model.Deployment.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_deployment(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.Deployment.t()} | {:error, Tesla.Env.t()}
def get_job_deployment(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/deployment")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.Deployment{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
- `:all` (integer()): Flag indicating whether to constrain by job creation index or not.
### Returns
- `{:ok, [%Deployment{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_deployments(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, list(NomadClient.Model.Deployment.t())} | {:error, Tesla.Env.t()}
def get_job_deployments(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query,
:all => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/deployments")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, [%NomadClient.Model.Deployment{}]},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, [%Evaluation{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_evaluations(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, list(NomadClient.Model.Evaluation.t())} | {:error, Tesla.Env.t()}
def get_job_evaluations(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/evaluations")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, [%NomadClient.Model.Evaluation{}]},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, NomadClient.Model.JobScaleStatusResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_scale_status(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, NomadClient.Model.JobScaleStatusResponse.t()}
| {:error, Tesla.Env.t()}
def get_job_scale_status(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/scale")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobScaleStatusResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, NomadClient.Model.JobSummary.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_summary(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.JobSummary.t()} | {:error, Tesla.Env.t()}
def get_job_summary(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/summary")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobSummary{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
- `:diffs` (boolean()): Boolean flag indicating whether to compute job diffs.
### Returns
- `{:ok, NomadClient.Model.JobVersionsResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_job_versions(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.JobVersionsResponse.t()} | {:error, Tesla.Env.t()}
def get_job_versions(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query,
:diffs => :query
}
request =
%{}
|> method(:get)
|> url("/job/#{job_name}/versions")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobVersionsResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:index` (integer()): If set, wait until query exceeds given index. Must be provided with WaitParam.
- `:wait` (String.t): Provided with IndexParam to wait for change.
- `:stale` (String.t): If present, results will include stale reads.
- `:prefix` (String.t): Constrains results to jobs that start with the defined prefix
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:per_page` (integer()): Maximum number of results to return.
- `:next_token` (String.t): Indicates where to start paging for queries that support pagination.
### Returns
- `{:ok, [%JobListStub{}, ...]}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_jobs(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:ok, list(NomadClient.Model.JobListStub.t())} | {:error, Tesla.Env.t()}
def get_jobs(connection, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:index => :headers,
:wait => :query,
:stale => :query,
:prefix => :query,
:"X-Nomad-Token" => :headers,
:per_page => :query,
:next_token => :query
}
request =
%{}
|> method(:get)
|> url("/jobs")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, [%NomadClient.Model.JobListStub{}]},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_register_request` (JobRegisterRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobRegisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobRegisterRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobRegisterResponse.t()} | {:error, Tesla.Env.t()}
def post_job(connection, job_name, job_register_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}")
|> add_param(:body, :body, job_register_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobRegisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_dispatch_request` (JobDispatchRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobDispatchResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_dispatch(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobDispatchRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobDispatchResponse.t()} | {:error, Tesla.Env.t()}
def post_job_dispatch(connection, job_name, job_dispatch_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/dispatch")
|> add_param(:body, :body, job_dispatch_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobDispatchResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_evaluate_request` (JobEvaluateRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobRegisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_evaluate(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobEvaluateRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobRegisterResponse.t()} | {:error, Tesla.Env.t()}
def post_job_evaluate(connection, job_name, job_evaluate_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/evaluate")
|> add_param(:body, :body, job_evaluate_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobRegisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `jobs_parse_request` (JobsParseRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, NomadClient.Model.Job.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_parse(Tesla.Env.client(), NomadClient.Model.JobsParseRequest.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.Job.t()} | {:error, Tesla.Env.t()}
def post_job_parse(connection, jobs_parse_request, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/jobs/parse")
|> add_param(:body, :body, jobs_parse_request)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.Job{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.PeriodicForceResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_periodic_force(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, NomadClient.Model.PeriodicForceResponse.t()}
| {:error, Tesla.Env.t()}
def post_job_periodic_force(connection, job_name, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/periodic/force")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.PeriodicForceResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_plan_request` (JobPlanRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobPlanResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_plan(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobPlanRequest.t(),
keyword()
) :: {:ok, nil} | {:ok, NomadClient.Model.JobPlanResponse.t()} | {:error, Tesla.Env.t()}
def post_job_plan(connection, job_name, job_plan_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/plan")
|> add_param(:body, :body, job_plan_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobPlanResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_revert_request` (JobRevertRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobRegisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_revert(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobRevertRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobRegisterResponse.t()} | {:error, Tesla.Env.t()}
def post_job_revert(connection, job_name, job_revert_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/revert")
|> add_param(:body, :body, job_revert_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobRegisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `scaling_request` (ScalingRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobRegisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_scaling_request(
Tesla.Env.client(),
String.t(),
NomadClient.Model.ScalingRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobRegisterResponse.t()} | {:error, Tesla.Env.t()}
def post_job_scaling_request(connection, job_name, scaling_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/scale")
|> add_param(:body, :body, scaling_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobRegisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_name` (String.t): The job identifier.
- `job_stability_request` (JobStabilityRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobStabilityResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_stability(
Tesla.Env.client(),
String.t(),
NomadClient.Model.JobStabilityRequest.t(),
keyword()
) ::
{:ok, nil} | {:ok, NomadClient.Model.JobStabilityResponse.t()} | {:error, Tesla.Env.t()}
def post_job_stability(connection, job_name, job_stability_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/job/#{job_name}/stable")
|> add_param(:body, :body, job_stability_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobStabilityResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_validate_request` (JobValidateRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobValidateResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec post_job_validate_request(
Tesla.Env.client(),
NomadClient.Model.JobValidateRequest.t(),
keyword()
) ::
{:ok, NomadClient.Model.JobValidateResponse.t()} | {:ok, nil} | {:error, Tesla.Env.t()}
def post_job_validate_request(connection, job_validate_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/validate/job")
|> add_param(:body, :body, job_validate_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobValidateResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
@doc """
### Parameters
- `connection` (NomadClient.Connection): Connection to server
- `job_register_request` (JobRegisterRequest):
- `opts` (keyword): Optional parameters
- `:region` (String.t): Filters results based on the specified region.
- `:namespace` (String.t): Filters results based on the specified namespace.
- `:x_nomad_token` (String.t): A Nomad ACL token.
- `:idempotency_token` (String.t): Can be used to ensure operations are only run once.
### Returns
- `{:ok, NomadClient.Model.JobRegisterResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec register_job(Tesla.Env.client(), NomadClient.Model.JobRegisterRequest.t(), keyword()) ::
{:ok, nil} | {:ok, NomadClient.Model.JobRegisterResponse.t()} | {:error, Tesla.Env.t()}
def register_job(connection, job_register_request, opts \\ []) do
optional_params = %{
:region => :query,
:namespace => :query,
:"X-Nomad-Token" => :headers,
:idempotency_token => :query
}
request =
%{}
|> method(:post)
|> url("/jobs")
|> add_param(:body, :body, job_register_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %NomadClient.Model.JobRegisterResponse{}},
{400, false},
{403, false},
{405, false},
{500, false}
])
end
end