Class: Docker::Swarm::Node
- Inherits:
-
Object
- Object
- Docker::Swarm::Node
- Includes:
- Base
- Defined in:
- lib/docker/swarm/node.rb
Overview
This class represents a Docker Swarm Node.
Class Method Summary collapse
- .all(opts = {}, conn = Docker.connection) ⇒ Object
- .by_name(node_name, opts = {}, conn = Docker.connection) ⇒ Object
- .get(id, opts = {}, conn = Docker.connection) ⇒ Object
Class Method Details
.all(opts = {}, conn = Docker.connection) ⇒ Object
21 22 23 24 |
# File 'lib/docker/swarm/node.rb', line 21 def all(opts = {}, conn = Docker.connection) hashes = Docker::Util.parse_json(conn.get('/nodes', opts)) || [] hashes.map { |hash| new(conn, hash) } end |
.by_name(node_name, opts = {}, conn = Docker.connection) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/docker/swarm/node.rb', line 14 def by_name(node_name, opts = {}, conn = Docker.connection) opts = opts.merge(filters: {"name" => [node_name]}.to_json) hashes = Docker::Util.parse_json(conn.get('/nodes', opts)) || [] hash = hashes.first new(conn, hash) if hash end |
.get(id, opts = {}, conn = Docker.connection) ⇒ Object
8 9 10 11 12 |
# File 'lib/docker/swarm/node.rb', line 8 def get(id, opts = {}, conn = Docker.connection) node_json = conn.get("/nodes/#{URI.encode(id)}", opts) hash = Docker::Util.parse_json(node_json) || {} new(conn, hash) end |