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 Method Summary collapse
-
#create(body = {}, authentication = {}) ⇒ Object
Create a service.
-
#delete(name) ⇒ Object
Delete 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.
-
#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 @connection.request(method: :post, path: "/services/create", headers: headers, body: body.to_json) end |
#delete(name) ⇒ Object
Delete a service
Docker API: DELETE /services/id
74 75 76 |
# File 'lib/docker/api/service.rb', line 74 def delete name @connection.delete("/services/#{name}") 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 = {} @connection.get(build_path("/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 = {} @connection.get(build_path("/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 = {} @connection.get(build_path("/services/#{name}/logs", params)) 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 @connection.request(method: :post, path: build_path("/services/#{name}/update", params), headers: headers, body: body.to_json) end |