class Docker::Api::ApiClient

Overview

Low-level wrapper for the Docker Engine API.

Each method on maps one-to-one with a REST API endpoint, and either returns the response that the API responds with or raises an Docker::ApiError. It's possible to use ApiClient directly if you require the extra flexibility, however in most cases the abstractions provided by the higher-level Docker::Client may be the better choice.

Included Modules

Defined in:

docker/api/api_client.cr

Constant Summary

DEFAULT_URL = "unix:///var/run/docker.sock"

Constructors

Instance Method Summary

Instance methods inherited from module Docker::Api::Images

build(path : String, **opts) build, images(all : Bool | Nil = nil, name : String | Nil = nil, filters : Hash | Nil = nil) images, inspect_image(id : String) inspect_image

Instance methods inherited from module Docker::Api::Daemon

ping ping, version version

Instance methods inherited from module Docker::Api::Containers

containers(all : Bool | Nil = nil, limit : Int | Nil = nil, size : Bool | Nil = nil, filters : Hash | Nil = nil) containers, create_container(name : String | Nil = nil, **props) create_container, inspect_container(id : String) inspect_container, kill(id : String, signal : String | Nil = nil) kill, pause(id : String) pause, remove_container(id : String, v : Bool | Nil = nil, force : Bool | Nil = nil, link : Bool | Nil = nil) remove_container, rename(id : String, name : String) rename, restart(id : String, timeout : Int | Nil = nil) restart, start(id : String) start, stop(id : String, timeout : Int | Nil = nil) stop, unpause(id : String) unpause, update(id : String, **props) update, wait(id : String, condition : String | Nil = nil) wait

Constructor Detail

def self.new(base_url = DEFAULT_URL, api_version : Nil | String = nil) #

[View source]

Instance Method Detail

def api_version : String | Nil #

API version in use, defaults to latest if nil


[View source]
def connection : HTTP::Client #

:no_doc: Underlying HTTP connection - exposed for access from test framework only.


[View source]
def delete(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a DELETE request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def delete(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a DELETE request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def delete(path, body : NamedTuple) #

Executes a DELETE request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def delete(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a DELETE request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def delete(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a DELETE request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def delete(path, body : NamedTuple, &) #

Executes a DELETE request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def get(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a GET request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def get(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a GET request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def get(path, body : NamedTuple) #

Executes a GET request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def get(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a GET request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def get(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a GET request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def get(path, body : NamedTuple, &) #

Executes a GET request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def head(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a HEAD request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def head(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a HEAD request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def head(path, body : NamedTuple) #

Executes a HEAD request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def head(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a HEAD request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def head(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a HEAD request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def head(path, body : NamedTuple, &) #

Executes a HEAD request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def options(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a OPTIONS request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def options(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a OPTIONS request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def options(path, body : NamedTuple) #

Executes a OPTIONS request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def options(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a OPTIONS request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def options(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a OPTIONS request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def options(path, body : NamedTuple, &) #

Executes a OPTIONS request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def patch(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a PATCH request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def patch(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a PATCH request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def patch(path, body : NamedTuple) #

Executes a PATCH request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def patch(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a PATCH request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def patch(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a PATCH request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def patch(path, body : NamedTuple, &) #

Executes a PATCH request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def post(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a POST request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def post(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a POST request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def post(path, body : NamedTuple) #

Executes a POST request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def post(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a POST request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def post(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a POST request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def post(path, body : NamedTuple, &) #

Executes a POST request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def put(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a PUT request on the docker client connection.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def put(path, headers : HTTP::Headers, body : NamedTuple) #

Executes a PUT request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def put(path, body : NamedTuple) #

Executes a PUT request on the docker client connection with a JSON body formed from the passed NamedTuple.


[View source]
def put(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a PUT request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a Docker::ApiError raised if unsuccessful.


[View source]
def put(path, headers : HTTP::Headers, body : NamedTuple, &) #

Executes a PUT request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def put(path, body : NamedTuple, &) #

Executes a PUT request on the docker client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]