Class: DockerEngineAPI::Resources::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_engine_api/resources/services.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Services

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Services.

Parameters:



190
191
192
# File 'lib/docker_engine_api/resources/services.rb', line 190

def initialize(client:)
  @client = client
end

Instance Method Details

#create(spec:, x_registry_auth: nil, request_options: {}) ⇒ DockerEngineAPI::Models::CreateResponse

Some parameter documentations has been truncated, see Models::ServiceCreateParams for more details.

Create a service

Parameters:

Returns:

See Also:



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/docker_engine_api/resources/services.rb', line 22

def create(params)
  parsed, options = DockerEngineAPI::ServiceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "services/create",
    headers: parsed.except(:spec).transform_keys(x_registry_auth: "x-registry-auth"),
    body: parsed[:spec],
    model: DockerEngineAPI::CreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Delete a service

Parameters:

Returns:

  • (nil)

See Also:



110
111
112
113
114
115
116
117
# File 'lib/docker_engine_api/resources/services.rb', line 110

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["services/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#inspect_(id, insert_defaults: nil, request_options: {}) ⇒ DockerEngineAPI::Models::Service

Inspect a service

Parameters:

  • id (String)

    ID or name of service.

  • insert_defaults (Boolean)

    Fill empty fields with default values.

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



132
133
134
135
136
137
138
139
140
141
# File 'lib/docker_engine_api/resources/services.rb', line 132

def inspect_(id, params = {})
  parsed, options = DockerEngineAPI::ServiceInspectParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["services/%1$s", id],
    query: parsed.transform_keys(insert_defaults: "insertDefaults"),
    model: DockerEngineAPI::Service,
    options: options
  )
end

#list(filters: nil, status: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::Service>

Some parameter documentations has been truncated, see Models::ServiceListParams for more details.

List services

Parameters:

  • filters (String)

    A JSON encoded value of the filters (a map[string][]string) to

  • status (Boolean)

    Include service status, with count of running and desired tasks.

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
# File 'lib/docker_engine_api/resources/services.rb', line 88

def list(params = {})
  parsed, options = DockerEngineAPI::ServiceListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "services",
    query: parsed,
    model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::Service],
    options: options
  )
end

#logs(id, details: nil, follow: nil, since: nil, stderr: nil, stdout: nil, tail: nil, timestamps: nil, request_options: {}) ⇒ StringIO

Some parameter documentations has been truncated, see Models::ServiceLogsParams for more details.

Get stdout and stderr logs from a service. See also [‘/containers/id/logs`](#operation/ContainerLogs).

Note: This endpoint works only for services with the local, json-file or journald logging drivers.

Parameters:

  • id (String)

    ID or name of the service

  • details (Boolean)

    Show service context and extra details provided to logs.

  • follow (Boolean)

    Keep connection after returning logs.

  • since (Integer)

    Only return logs since this time, as a UNIX timestamp

  • stderr (Boolean)

    Return logs from stderr

  • stdout (Boolean)

    Return logs from stdout

  • tail (String)

    Only return this number of log lines from the end of the logs.

  • timestamps (Boolean)

    Add timestamps to every log line

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (StringIO)

See Also:



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/docker_engine_api/resources/services.rb', line 175

def logs(id, params = {})
  parsed, options = DockerEngineAPI::ServiceLogsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["services/%1$s/logs", id],
    query: parsed,
    headers: {"accept" => "application/vnd.docker.multiplexed-stream"},
    model: StringIO,
    options: options
  )
end

#update(id, version:, spec:, registry_auth_from: nil, rollback: nil, x_registry_auth: nil, request_options: {}) ⇒ DockerEngineAPI::Models::UpdateResponse

Some parameter documentations has been truncated, see Models::ServiceUpdateParams for more details.

Update a service

Parameters:

  • id (String)

    Path param: ID or name of service.

  • version (Integer)

    Query param: The version number of the service object being updated. This is

  • spec (DockerEngineAPI::Models::ServiceUpdateParams::Spec)

    Body param: User modifiable configuration for a service.

  • registry_auth_from (Symbol, DockerEngineAPI::Models::ServiceUpdateParams::RegistryAuthFrom)

    Query param: If the X-Registry-Auth header is not specified, this parameter

  • rollback (String)

    Query param: Set to this parameter to previous to cause a server-side rollback

  • x_registry_auth (String)

    Header param: A base64url-encoded auth configuration for pulling from private

  • request_options (DockerEngineAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/docker_engine_api/resources/services.rb', line 58

def update(id, params)
  parsed, options = DockerEngineAPI::ServiceUpdateParams.dump_request(params)
  query_params = [:version, :registry_auth_from, :rollback]
  @client.request(
    method: :post,
    path: ["services/%1$s/update", id],
    query: parsed.slice(*query_params).transform_keys(registry_auth_from: "registryAuthFrom"),
    headers: parsed.except(:spec, *query_params).transform_keys(x_registry_auth: "x-registry-auth"),
    body: parsed[:spec],
    model: DockerEngineAPI::UpdateResponse,
    options: options
  )
end