Class: Docker::API::Secret

Inherits:
Base
  • Object
show all
Defined in:
lib/docker/api/secret.rb

Overview

This class represents the Docker API endpoints regarding secrets.

Secrets are sensitive data that can be used by services. Swarm mode must be enabled for these endpoints to work.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Docker::API::Base

Instance Method Details

#create(body = {}) ⇒ Object

Create a secret

Docker API: POST /secrets/create

Parameters:

  • body (Hash) (defaults to: {})

    : Request body to be sent as json.

See Also:



23
24
25
# File 'lib/docker/api/secret.rb', line 23

def create body = {}
    @connection.request(method: :post, path: "/secrets/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
end

#delete(name) ⇒ Object

Delete a secret

Docker API: DELETE /secrets/id

Parameters:

  • name (String)

    : The ID or name of the secret.

See Also:



55
56
57
# File 'lib/docker/api/secret.rb', line 55

def delete name
    @connection.delete("/secrets/#{name}")
end

#details(name) ⇒ Object

Inspect a secret

Docker API: GET /secrets/id

Parameters:

  • name (String)

    : The ID or name of the secret.

See Also:



33
34
35
# File 'lib/docker/api/secret.rb', line 33

def details name
    @connection.get("/secrets/#{name}")
end

#list(params = {}) ⇒ Object

List secrets

Docker API: GET /secrets

Parameters:

  • params (Hash) (defaults to: {})

    : Parameters that are appended to the URL.

See Also:



13
14
15
# File 'lib/docker/api/secret.rb', line 13

def list params = {}
    @connection.get(build_path("/secrets",params))
end

#update(name, params = {}, body = {}) ⇒ Object

Update a secret

Docker API: POST /secrets/id/update

Parameters:

  • name (String)

    : The ID or name of the secret.

  • params (Hash) (defaults to: {})

    : Parameters that are appended to the URL.

  • body (Hash) (defaults to: {})

    : Request body to be sent as json.

See Also:



45
46
47
# File 'lib/docker/api/secret.rb', line 45

def update name, params = {}, body = {}
    @connection.request(method: :post, path: build_path("/secrets/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
end