Crates.io | docker-rust-api |
lib.rs | docker-rust-api |
version | 1.42.1 |
source | src |
created_at | 2023-03-01 07:46:46.054864 |
updated_at | 2023-03-01 08:04:29.723866 |
description | The Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API. Most of the client's commands map directly to API endpoints (e.g. `docker ps` is `GET /containers/json`). The notable exception is running containers, which consists of several API calls. # Errors The API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format: ``` { "message": "page not found" } ``` # Versioning The API is usually changed in each release, so API calls are versioned to ensure that clients don't break. To lock to a specific version of the API, you prefix the URL with its version, for example, call `/v1.30/info` to use the v1.30 version of the `/info` endpoint. If the API version specified in the URL is not supported by the daemon, a HTTP `400 Bad Request` error message is returned. If you omit the version-prefix, the current version of the API (v1.42) is used. For example, calling `/info` is the same as calling `/v1.42/info`. Using the API without a version-prefix is deprecated and will be removed in a future release. Engine releases in the near future should support this version of the API, so your client will continue to work even if it is talking to a newer Engine. The API uses an open schema model, which means server may add extra properties to responses. Likewise, the server will ignore any extra query parameters and request body properties. When you write clients, you need to ignore additional properties in responses to ensure they do not break when talking to newer daemons. # Authentication Authentication for registries is handled client side. The client has to send authentication details to various endpoints that need to communicate with registries, such as `POST /images/(name)/push`. These are sent as `X-Registry-Auth` header as a [base64url encoded](https://tools.ietf.org/html/rfc4648#section-5) (JSON) string with the following structure: ``` { "username": "string", "password": "string", "email": "string", "serveraddress": "string" } ``` The `serveraddress` is a domain/IP without a protocol. Throughout this structure, double quotes are required. If you have already got an identity token from the [`/auth` endpoint](#operation/SystemAuth), you can just pass this instead of credentials: ``` { "identitytoken": "9cbaf023786cd7..." } ``` |
homepage | |
repository | https://github.com/alfiankan/docker-rust-api |
max_upload_size | |
id | 797819 |
size | 2,039,808 |
The Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API.
Most of the client's commands map directly to API endpoints (e.g. docker ps
is GET /containers/json
). The notable exception is running containers,
which consists of several API calls.
async fn list_containers(config: &Configuration) {
let containers = container_list(config, Some(true), None, None, None);
match containers.await {
Ok(container_summary) => {
for c in container_summary {
println!("{:?}", c.names);
}
}
Err(err) => {
panic!("{}", err)
}
}
}
fn main() {
println!("DOCKER");
let config = &Configuration {
base_path: "http://127.0.0.1:2375".to_string(),
user_agent: None,
client: reqwest::Client::new(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
};
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(async {
list_containers(config).await;
})
}
cargo add docker-rust-api
The API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format:
{
\"message\": \"page not found\"
}
The API is usually changed in each release, so API calls are versioned to
ensure that clients don't break. To lock to a specific version of the API,
you prefix the URL with its version, for example, call /v1.30/info
to use
the v1.30 version of the /info
endpoint. If the API version specified in
the URL is not supported by the daemon, a HTTP 400 Bad Request
error message
is returned.
If you omit the version-prefix, the current version of the API (v1.42) is used.
For example, calling /info
is the same as calling /v1.42/info
. Using the
API without a version-prefix is deprecated and will be removed in a future release.
Engine releases in the near future should support this version of the API, so your client will continue to work even if it is talking to a newer Engine.
The API uses an open schema model, which means server may add extra properties to responses. Likewise, the server will ignore any extra query parameters and request body properties. When you write clients, you need to ignore additional properties in responses to ensure they do not break when talking to newer daemons.
Authentication for registries is handled client side. The client has to send
authentication details to various endpoints that need to communicate with
registries, such as POST /images/(name)/push
. These are sent as
X-Registry-Auth
header as a base64url encoded
(JSON) string with the following structure:
{
\"username\": \"string\",
\"password\": \"string\",
\"email\": \"string\",
\"serveraddress\": \"string\"
}
The serveraddress
is a domain/IP without a protocol. Throughout this
structure, double quotes are required.
If you have already got an identity token from the /auth
endpoint,
you can just pass this instead of credentials:
{
\"identitytoken\": \"9cbaf023786cd7...\"
}
This API client was generated by the OpenAPI Generator project. By using the openapi-spec from a remote server, you can easily generate an API client.
org.openapitools.codegen.languages.RustClientCodegen
Put the package under your project folder in a directory named openapi
and add the following to Cargo.toml
under [dependencies]
:
openapi = { path = "./openapi" }
All URIs are relative to http://localhost/v1.42
Class | Method | HTTP request | Description |
---|
ConfigApi | config_create | POST /configs/create | Create a config ConfigApi | config_delete | DELETE /configs/{id} | Delete a config ConfigApi | config_inspect | GET /configs/{id} | Inspect a config ConfigApi | config_list | GET /configs | List configs ConfigApi | config_update | POST /configs/{id}/update | Update a Config ContainerApi | container_archive | GET /containers/{id}/archive | Get an archive of a filesystem resource in a container ContainerApi | container_archive_info | HEAD /containers/{id}/archive | Get information about files in a container ContainerApi | container_attach | POST /containers/{id}/attach | Attach to a container ContainerApi | container_attach_websocket | GET /containers/{id}/attach/ws | Attach to a container via a websocket ContainerApi | container_changes | GET /containers/{id}/changes | Get changes on a container’s filesystem ContainerApi | container_create | POST /containers/create | Create a container ContainerApi | container_delete | DELETE /containers/{id} | Remove a container ContainerApi | container_export | GET /containers/{id}/export | Export a container ContainerApi | container_inspect | GET /containers/{id}/json | Inspect a container ContainerApi | container_kill | POST /containers/{id}/kill | Kill a container ContainerApi | container_list | GET /containers/json | List containers ContainerApi | container_logs | GET /containers/{id}/logs | Get container logs ContainerApi | container_pause | POST /containers/{id}/pause | Pause a container ContainerApi | container_prune | POST /containers/prune | Delete stopped containers ContainerApi | container_rename | POST /containers/{id}/rename | Rename a container ContainerApi | container_resize | POST /containers/{id}/resize | Resize a container TTY ContainerApi | container_restart | POST /containers/{id}/restart | Restart a container ContainerApi | container_start | POST /containers/{id}/start | Start a container ContainerApi | container_stats | GET /containers/{id}/stats | Get container stats based on resource usage ContainerApi | container_stop | POST /containers/{id}/stop | Stop a container ContainerApi | container_top | GET /containers/{id}/top | List processes running inside a container ContainerApi | container_unpause | POST /containers/{id}/unpause | Unpause a container ContainerApi | container_update | POST /containers/{id}/update | Update a container ContainerApi | container_wait | POST /containers/{id}/wait | Wait for a container ContainerApi | put_container_archive | PUT /containers/{id}/archive | Extract an archive of files or folders to a directory in a container DistributionApi | distribution_inspect | GET /distribution/{name}/json | Get image information from the registry ExecApi | container_exec | POST /containers/{id}/exec | Create an exec instance ExecApi | exec_inspect | GET /exec/{id}/json | Inspect an exec instance ExecApi | exec_resize | POST /exec/{id}/resize | Resize an exec instance ExecApi | exec_start | POST /exec/{id}/start | Start an exec instance ImageApi | build_prune | POST /build/prune | Delete builder cache ImageApi | image_build | POST /build | Build an image ImageApi | image_commit | POST /commit | Create a new image from a container ImageApi | image_create | POST /images/create | Create an image ImageApi | image_delete | DELETE /images/{name} | Remove an image ImageApi | image_get | GET /images/{name}/get | Export an image ImageApi | image_get_all | GET /images/get | Export several images ImageApi | image_history | GET /images/{name}/history | Get the history of an image ImageApi | image_inspect | GET /images/{name}/json | Inspect an image ImageApi | image_list | GET /images/json | List Images ImageApi | image_load | POST /images/load | Import images ImageApi | image_prune | POST /images/prune | Delete unused images ImageApi | image_push | POST /images/{name}/push | Push an image ImageApi | image_search | GET /images/search | Search images ImageApi | image_tag | POST /images/{name}/tag | Tag an image NetworkApi | network_connect | POST /networks/{id}/connect | Connect a container to a network NetworkApi | network_create | POST /networks/create | Create a network NetworkApi | network_delete | DELETE /networks/{id} | Remove a network NetworkApi | network_disconnect | POST /networks/{id}/disconnect | Disconnect a container from a network NetworkApi | network_inspect | GET /networks/{id} | Inspect a network NetworkApi | network_list | GET /networks | List networks NetworkApi | network_prune | POST /networks/prune | Delete unused networks NodeApi | node_delete | DELETE /nodes/{id} | Delete a node NodeApi | node_inspect | GET /nodes/{id} | Inspect a node NodeApi | node_list | GET /nodes | List nodes NodeApi | node_update | POST /nodes/{id}/update | Update a node PluginApi | get_plugin_privileges | GET /plugins/privileges | Get plugin privileges PluginApi | plugin_create | POST /plugins/create | Create a plugin PluginApi | plugin_delete | DELETE /plugins/{name} | Remove a plugin PluginApi | plugin_disable | POST /plugins/{name}/disable | Disable a plugin PluginApi | plugin_enable | POST /plugins/{name}/enable | Enable a plugin PluginApi | plugin_inspect | GET /plugins/{name}/json | Inspect a plugin PluginApi | plugin_list | GET /plugins | List plugins PluginApi | plugin_pull | POST /plugins/pull | Install a plugin PluginApi | plugin_push | POST /plugins/{name}/push | Push a plugin PluginApi | plugin_set | POST /plugins/{name}/set | Configure a plugin PluginApi | plugin_upgrade | POST /plugins/{name}/upgrade | Upgrade a plugin SecretApi | secret_create | POST /secrets/create | Create a secret SecretApi | secret_delete | DELETE /secrets/{id} | Delete a secret SecretApi | secret_inspect | GET /secrets/{id} | Inspect a secret SecretApi | secret_list | GET /secrets | List secrets SecretApi | secret_update | POST /secrets/{id}/update | Update a Secret ServiceApi | service_create | POST /services/create | Create a service ServiceApi | service_delete | DELETE /services/{id} | Delete a service ServiceApi | service_inspect | GET /services/{id} | Inspect a service ServiceApi | service_list | GET /services | List services ServiceApi | service_logs | GET /services/{id}/logs | Get service logs ServiceApi | service_update | POST /services/{id}/update | Update a service SessionApi | session | POST /session | Initialize interactive session SwarmApi | swarm_init | POST /swarm/init | Initialize a new swarm SwarmApi | swarm_inspect | GET /swarm | Inspect swarm SwarmApi | swarm_join | POST /swarm/join | Join an existing swarm SwarmApi | swarm_leave | POST /swarm/leave | Leave a swarm SwarmApi | swarm_unlock | POST /swarm/unlock | Unlock a locked manager SwarmApi | swarm_unlockkey | GET /swarm/unlockkey | Get the unlock key SwarmApi | swarm_update | POST /swarm/update | Update a swarm SystemApi | system_auth | POST /auth | Check auth configuration SystemApi | system_data_usage | GET /system/df | Get data usage information SystemApi | system_events | GET /events | Monitor events SystemApi | system_info | GET /info | Get system information SystemApi | system_ping | GET /_ping | Ping SystemApi | system_ping_head | HEAD /_ping | Ping SystemApi | system_version | GET /version | Get version TaskApi | task_inspect | GET /tasks/{id} | Inspect a task TaskApi | task_list | GET /tasks | List tasks TaskApi | task_logs | GET /tasks/{id}/logs | Get task logs VolumeApi | volume_create | POST /volumes/create | Create a volume VolumeApi | volume_delete | DELETE /volumes/{name} | Remove a volume VolumeApi | volume_inspect | GET /volumes/{name} | Inspect a volume VolumeApi | volume_list | GET /volumes | List volumes VolumeApi | volume_prune | POST /volumes/prune | Delete unused volumes VolumeApi | volume_update | PUT /volumes/{name} | "Update a volume. Valid only for Swarm cluster volumes"
To get access to the crate's generated documentation, use:
cargo doc --open