Class: Algo::Docker::Service
Defined Under Namespace
Classes: Spec
Instance Attribute Summary collapse
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Attributes inherited from Base
Class Method Summary collapse
- .all(conn = Docker.connection) ⇒ Object
- .create(init_spec, conn = Docker.connection) ⇒ Object
- .find(id_or_name, conn = Docker.connection) ⇒ Object
- .remove(id_or_name, conn = Docker.connection) ⇒ Object
- .update(id_or_name, version, next_spec, conn = Docker.connection) ⇒ Object
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(conn, hash) ⇒ Service
constructor
A new instance of Service.
- #inspect ⇒ Object
- #raw_spec ⇒ Object
- #remove ⇒ Object
- #update(next_spec) ⇒ Object
Constructor Details
#initialize(conn, hash) ⇒ Service
Returns a new instance of Service.
12 13 14 15 |
# File 'lib/algo/docker/service.rb', line 12 def initialize conn, hash super(conn, hash) @spec = nil end |
Instance Attribute Details
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
10 11 12 |
# File 'lib/algo/docker/service.rb', line 10 def spec @spec end |
Class Method Details
.all(conn = Docker.connection) ⇒ Object
75 76 77 78 |
# File 'lib/algo/docker/service.rb', line 75 def self.all(conn=Docker.connection) hashes = conn.get('/services') hashes.map{ |h| new(conn, h) } end |
.create(init_spec, conn = Docker.connection) ⇒ Object
61 62 63 |
# File 'lib/algo/docker/service.rb', line 61 def self.create(init_spec, conn=Docker.connection) new(conn, conn.post('/services/create', nil, body: JSON.generate(init_spec))) end |
.find(id_or_name, conn = Docker.connection) ⇒ Object
57 58 59 |
# File 'lib/algo/docker/service.rb', line 57 def self.find(id_or_name, conn=Docker.connection) new(conn, conn.get("/services/#{id_or_name}")) end |
.remove(id_or_name, conn = Docker.connection) ⇒ Object
65 66 67 |
# File 'lib/algo/docker/service.rb', line 65 def self.remove(id_or_name, conn=Docker.connection) conn.delete("/services/#{id_or_name}") end |
.update(id_or_name, version, next_spec, conn = Docker.connection) ⇒ Object
69 70 71 72 73 |
# File 'lib/algo/docker/service.rb', line 69 def self.update(id_or_name, version, next_spec, conn=Docker.connection) conn.post("/services/#{id_or_name}/update", { version: version }, body: JSON.generate(next_spec)) end |
Instance Method Details
#info ⇒ Object
17 18 19 20 |
# File 'lib/algo/docker/service.rb', line 17 def info @info = Docker::Service.find(@info["Id"]).info if @info["Spec"].blank? @info end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/algo/docker/service.rb', line 44 def inspect "<Algo::Docker::Service name=#{spec.name}>" end |
#raw_spec ⇒ Object
40 41 42 |
# File 'lib/algo/docker/service.rb', line 40 def raw_spec info["Spec"] end |
#remove ⇒ Object
48 49 50 |
# File 'lib/algo/docker/service.rb', line 48 def remove self.class.remove info['Id'] end |
#update(next_spec) ⇒ Object
52 53 54 55 |
# File 'lib/algo/docker/service.rb', line 52 def update next_spec self.class.update info['Id'], info['Version']['Index'], next_spec @info = self.class.find(@info["Id"]).info end |