Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions lib/nomad/api/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ def read(name, **options)
json = client.get("/v1/job/#{CGI.escape(name)}", options)
return JobVersion.decode(json)
end

# Stops the job with the given name.
#
# @param [String] name The job name (ID).
#
# @return [JobStop]
def stop(name, **options)
json = client.delete("/v1/job/#{CGI.escape(name)}", options)
return JobStop.decode(json)
end
end

class JobItem < Response
Expand Down Expand Up @@ -1030,4 +1040,22 @@ class JobDispatchPayload < Response
# @return [String]
field :File, as: :file, load: :string_as_nil
end

class JobStop < Response
# @!attribute [r] eval_id
# The job eval_id.
# @return [String]
field :EvalID, as: :eval_id, load: :string_as_nil

# @!attribute [r] eval_create_index
# The job eval_create_index.
# @return [Integer]
field :EvalCreateIndex, as: :eval_create_index

# @!attribute [r] job_modify_index
# The job job_modify_index.
# @return [Integer]
field :JobModifyIndex, as: :job_modify_index

end
end
2 changes: 1 addition & 1 deletion lib/nomad/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Nomad
VERSION = "0.1.0"
VERSION = "0.2.0"
end
10 changes: 10 additions & 0 deletions spec/integration/api/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ module Nomad
end
end

describe "#stop" do
it "stops a job" do
job = JSON.parse(File.read(File.expand_path("../../../support/jobs/job.json", __FILE__)))
subject.create(job)
result = subject.stop("job")

expect(result).to be_a(JobStop)
end
end

describe "#read" do
it "reads a job" do
job = subject.read("job")
Expand Down