Class: Docker::API::Service
Overview
This class represents the Docker API endpoints regarding services.
Services are the definitions of tasks to run on a swarm. Swarm mode must be enabled for these endpoints to work.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(body = {}, authentication = {}) ⇒ Object
Create a service.
-
#details(name, params = {}) ⇒ Object
Inspect a service.
-
#list(params = {}) ⇒ Object
List services.
-
#logs(name, params = {}) ⇒ Object
Get stdout and stderr logs from a service.
-
#remove(name) ⇒ Object
Delete a service.
-
#update(name, params = {}, body = {}, authentication = {}) ⇒ Object
Update a service.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Docker::API::Base
Instance Method Details
#create(body = {}, authentication = {}) ⇒ Object
Create a service
Docker API: POST /services/create
24 25 26 27 28 |
# File 'lib/docker/api/service.rb', line 24 def create body = {}, authentication = {} headers = {"Content-Type" => "application/json"} headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0 request(method: :post, path: "/services/create", headers: headers, body: body.to_json) end |
#details(name, params = {}) ⇒ Object
Inspect a service
Docker API: GET /services/id
53 54 55 |
# File 'lib/docker/api/service.rb', line 53 def details name, params = {} get("/services/#{name}", params) end |
#list(params = {}) ⇒ Object
List services
Docker API: GET /services
13 14 15 |
# File 'lib/docker/api/service.rb', line 13 def list params = {} get("/services", params) end |
#logs(name, params = {}) ⇒ Object
Get stdout and stderr logs from a service.
Docker API: GET /services/id/logs
64 65 66 |
# File 'lib/docker/api/service.rb', line 64 def logs name, params = {} get("/services/#{name}/logs", params) end |
#remove(name) ⇒ Object
Delete a service
Docker API: DELETE /services/id
74 75 76 |
# File 'lib/docker/api/service.rb', line 74 def remove name delete("/services/#{name}") end |
#update(name, params = {}, body = {}, authentication = {}) ⇒ Object
Update a service
Docker API: POST /services/id/update
39 40 41 42 43 44 |
# File 'lib/docker/api/service.rb', line 39 def update name, params = {}, body = {}, authentication = {} # view https://github.com/docker/swarmkit/issues/1394#issuecomment-240850719 headers = {"Content-Type" => "application/json"} headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0 request(method: :post, path: "/services/#{name}/update", params: params, headers: headers, body: body.to_json) end |