Class: Docker::Swarm::Task
- Inherits:
-
Object
- Object
- Docker::Swarm::Task
- Includes:
- Base
- Defined in:
- lib/docker/swarm/task.rb
Overview
This class represents a Docker Swarm Task.
Class Method Summary collapse
- .all(opts = {}, conn = Docker.connection) ⇒ Object
- .get(id, opts = {}, conn = Docker.connection) ⇒ Object
Instance Method Summary collapse
Class Method Details
.all(opts = {}, conn = Docker.connection) ⇒ Object
28 29 30 31 |
# File 'lib/docker/swarm/task.rb', line 28 def all(opts = {}, conn = Docker.connection) hashes = Docker::Util.parse_json(conn.get('/tasks', opts)) || [] hashes.map { |hash| new(conn, hash) } end |
.get(id, opts = {}, conn = Docker.connection) ⇒ Object
22 23 24 25 26 |
# File 'lib/docker/swarm/task.rb', line 22 def get(id, opts = {}, conn = Docker.connection) task_json = conn.get("/tasks/#{URI.encode(id)}", opts) hash = Docker::Util.parse_json(task_json) || {} new(conn, hash) end |
Instance Method Details
#node ⇒ Object
9 10 11 |
# File 'lib/docker/swarm/task.rb', line 9 def node Docker::Node.get(self.info["NodeID"]) end |
#running? ⇒ Boolean
17 18 19 |
# File 'lib/docker/swarm/task.rb', line 17 def running? self.state == :running end |
#service ⇒ Object
5 6 7 |
# File 'lib/docker/swarm/task.rb', line 5 def service Docker::Service.get(self.info["ServiceID"]) end |
#state ⇒ Object
13 14 15 |
# File 'lib/docker/swarm/task.rb', line 13 def state self.info['Status']['State'].intern end |