class Nomad::Job

Public Instance Methods

create(contents, **options) click to toggle source

Create the job based on the given contents. The contents can be a string or a hash.

@param [String] contents

the raw JSON contents

@param [Hash] contents

a hash of the contents to convert to JSON

@return [JobCreate]

# File lib/nomad/api/job.rb, line 37
def create(contents, **options)
  body = contents.is_a?(Hash) ? JSON.fast_generate(contents) : contents
  json = client.post("/v1/jobs", body, options)
  return JobCreate.decode(json)
end
list(**options) click to toggle source

Get the address and port of the current leader for this region

@example

Nomad.job.list #=> [#<JobItem ...>]

@option [String] :prefix

filter based on the given prefix

@return [Array<JobItem>]

# File lib/nomad/api/job.rb, line 23
def list(**options)
  json = client.get("/v1/jobs", options)
  return json.map { |item| JobItem.decode(item) }
end
read(name, **options) click to toggle source

Reads the job with the given name.

@param [String] name The job name (ID).

@return [JobVersion]

# File lib/nomad/api/job.rb, line 48
def read(name, **options)
  json = client.get("/v1/job/#{CGI.escape(name)}", options)
  return JobVersion.decode(json)
end