Class: Docker::Swarm::Task
- Inherits:
-
Object
- Object
- Docker::Swarm::Task
- Defined in:
- lib/docker/swarm/task.rb
Overview
This class represents a Docker Swarm Node.
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
include Docker::Base.
Class Method Summary collapse
-
.all(opts = {}, conn = Docker.connection) ⇒ Object
Return all of the Nodes.
Instance Method Summary collapse
- #created_at ⇒ Object
- #id ⇒ Object
- #image ⇒ Object
-
#initialize(hash) ⇒ Task
constructor
A new instance of Task.
- #node_id ⇒ Object
- #service_id ⇒ Object
- #status ⇒ Object
Constructor Details
permalink #initialize(hash) ⇒ Task
Returns a new instance of Task.
6 7 8 |
# File 'lib/docker/swarm/task.rb', line 6 def initialize(hash) @hash = hash end |
Instance Attribute Details
permalink #hash ⇒ Object (readonly)
include Docker::Base
4 5 6 |
# File 'lib/docker/swarm/task.rb', line 4 def hash @hash end |
Class Method Details
permalink .all(opts = {}, conn = Docker.connection) ⇒ Object
Return all of the Nodes.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/docker/swarm/task.rb', line 35 def self.all(opts = {}, conn = Docker.connection) raise "opts needs to be hash" if (opts.class != Hash) query = {} resp = conn.get('/tasks', query, :body => opts.to_json) hashes = JSON.parse(resp) items = [] hashes.each do |hash| items << Docker::Swarm::Task.new(hash) end return items end |
Instance Method Details
permalink #created_at ⇒ Object
[View source]
26 27 28 |
# File 'lib/docker/swarm/task.rb', line 26 def created_at return DateTime.parse(@hash.first['CreatedAt']) end |
permalink #id ⇒ Object
[View source]
10 11 12 |
# File 'lib/docker/swarm/task.rb', line 10 def id return @hash['ID'] end |
permalink #image ⇒ Object
[View source]
14 15 16 |
# File 'lib/docker/swarm/task.rb', line 14 def image return @hash['Spec']['ContainerSpec']['Image'] end |
permalink #node_id ⇒ Object
[View source]
22 23 24 |
# File 'lib/docker/swarm/task.rb', line 22 def node_id @hash['NodeID'] end |
permalink #service_id ⇒ Object
[View source]
18 19 20 |
# File 'lib/docker/swarm/task.rb', line 18 def service_id @hash['ServiceID'] end |
permalink #status ⇒ Object
[View source]
30 31 32 |
# File 'lib/docker/swarm/task.rb', line 30 def status @hash['Status']['State'].to_sym end |