de.gesellix.docker.remote.api.client.ContainerApi.kt Maven / Gradle / Ivy
/**
* Docker Engine API
* 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.41) is used. For example, calling `/info` is the same as calling `/v1.41/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...\" } ```
*
* The version of the OpenAPI document: 1.41
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package de.gesellix.docker.remote.api.client
import de.gesellix.docker.engine.DockerClientConfig
import de.gesellix.docker.engine.RequestMethod.*
import de.gesellix.docker.remote.api.ContainerChangeResponseItem
import de.gesellix.docker.remote.api.ContainerCreateRequest
import de.gesellix.docker.remote.api.ContainerCreateResponse
import de.gesellix.docker.remote.api.ContainerInspectResponse
import de.gesellix.docker.remote.api.ContainerPruneResponse
import de.gesellix.docker.remote.api.ContainerTopResponse
import de.gesellix.docker.remote.api.ContainerUpdateRequest
import de.gesellix.docker.remote.api.ContainerUpdateResponse
import de.gesellix.docker.remote.api.ContainerWaitResponse
import de.gesellix.docker.remote.api.core.ApiClient
import de.gesellix.docker.remote.api.core.ClientError
import de.gesellix.docker.remote.api.core.ClientException
import de.gesellix.docker.remote.api.core.Frame
import de.gesellix.docker.remote.api.core.MultiValueMap
import de.gesellix.docker.remote.api.core.RequestConfig
import de.gesellix.docker.remote.api.core.ResponseType
import de.gesellix.docker.remote.api.core.ServerError
import de.gesellix.docker.remote.api.core.ServerException
import de.gesellix.docker.remote.api.core.StreamCallback
import de.gesellix.docker.remote.api.core.Success
import de.gesellix.docker.remote.api.core.SuccessStream
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import java.net.HttpURLConnection.HTTP_NOT_FOUND
import java.net.HttpURLConnection.HTTP_NOT_MODIFIED
import java.net.Proxy
class ContainerApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, proxy: Proxy?) : ApiClient(dockerClientConfig, proxy) {
constructor(dockerClientConfig: DockerClientConfig = defaultClientConfig) : this(dockerClientConfig, null)
companion object {
@JvmStatic
val defaultClientConfig: DockerClientConfig by lazy {
DockerClientConfig()
}
}
/**
* Get an archive of a filesystem resource in a container
* Get a tar archive of a resource in the filesystem of container id.
* @param id ID or name of the container
* @param path Resource in the container’s filesystem to archive.
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerArchive(id: String, path: String) {
val localVariableConfig = containerArchiveRequestConfig(id = id, path = path)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerArchive
*
* @param id ID or name of the container
* @param path Resource in the container’s filesystem to archive.
* @return RequestConfig
*/
fun containerArchiveRequestConfig(id: String, path: String): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
put("path", listOf(path))
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/containers/{id}/archive".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Get information about files in a container
* A response header `X-Docker-Container-Path-Stat` is returned, containing a base64 - encoded JSON object with some filesystem header information about the path.
* @param id ID or name of the container
* @param path Resource in the container’s filesystem to archive.
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerArchiveInfo(id: String, path: String) {
val localVariableConfig = containerArchiveInfoRequestConfig(id = id, path = path)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerArchiveInfo
*
* @param id ID or name of the container
* @param path Resource in the container’s filesystem to archive.
* @return RequestConfig
*/
fun containerArchiveInfoRequestConfig(id: String, path: String): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
put("path", listOf(path))
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = HEAD,
path = "/containers/{id}/archive".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Attach to a container
* Attach to a container to read its output or send it input. You can attach to the same container multiple times and you can reattach to containers that have been detached. Either the `stream` or `logs` parameter must be `true` for this endpoint to do anything. See the [documentation for the `docker attach` command](https://docs.docker.com/engine/reference/commandline/attach/) for more details. ### Hijacking This endpoint hijacks the HTTP connection to transport `stdin`, `stdout`, and `stderr` on the same socket. This is the response from the daemon for an attach request: ``` HTTP/1.1 200 OK Content-Type: application/vnd.docker.raw-stream [STREAM] ``` After the headers and two new lines, the TCP connection can now be used for raw, bidirectional communication between the client and server. To hint potential proxies about connection hijacking, the Docker client can also optionally send connection upgrade headers. For example, the client sends this request to upgrade the connection: ``` POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1 Upgrade: tcp Connection: Upgrade ``` The Docker daemon will respond with a `101 UPGRADED` response, and will similarly follow with the raw stream: ``` HTTP/1.1 101 UPGRADED Content-Type: application/vnd.docker.raw-stream Connection: Upgrade Upgrade: tcp [STREAM] ``` ### Stream format When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate), the stream over the hijacked connected is multiplexed to separate out `stdout` and `stderr`. The stream consists of a series of frames, each containing a header and a payload. The header contains the information which the stream writes (`stdout` or `stderr`). It also contains the size of the associated frame encoded in the last four bytes (`uint32`). It is encoded on the first eight bytes like this: ```go header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} ``` `STREAM_TYPE` can be: - 0: `stdin` (is written on `stdout`) - 1: `stdout` - 2: `stderr` `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the `uint32` size encoded as big endian. Following the header is the payload, which is the specified number of bytes of `STREAM_TYPE`. The simplest way to implement this protocol is the following: 1. Read 8 bytes. 2. Choose `stdout` or `stderr` depending on the first byte. 3. Extract the frame size from the last four bytes. 4. Read the extracted size and output it on the correct output. 5. Goto 1. ### Stream format when using a TTY When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate), the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client's `stdin`.
* @param id ID or name of the container
* @param detachKeys Override the key sequence for detaching a container.Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. (optional)
* @param logs Replay previous logs from the container. This is useful for attaching to a container that has started and you want to output everything since the container started. If `stream` is also enabled, once all the previous output has been returned, it will seamlessly transition into streaming current output. (optional, default to false)
* @param stream Stream attached streams from the time the request was made onwards. (optional, default to false)
* @param stdin Attach to `stdin` (optional, default to false)
* @param stdout Attach to `stdout` (optional, default to false)
* @param stderr Attach to `stderr` (optional, default to false)
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerAttach(
id: String, detachKeys: String?, logs: Boolean?, stream: Boolean?, stdin: Boolean?, stdout: Boolean?, stderr: Boolean?,
callback: StreamCallback, timeoutMillis: Long /*= 24.hours.toLongMilliseconds()*/
) {
val localVariableConfig = containerAttachRequestConfig(id = id, detachKeys = detachKeys, logs = logs, stream = stream, stdin = stdin, stdout = stdout, stderr = stderr)
val expectMultiplexedResponse = !(containerInspect(id, false).config?.tty ?: false)
val localVarResponse = requestFrames(
localVariableConfig, expectMultiplexedResponse
)
when (localVarResponse.responseType) {
ResponseType.Success -> {
runBlocking {
launch {
withTimeout(timeoutMillis) {
callback.onStarting(this@launch::cancel)
((localVarResponse as SuccessStream<*>).data as Flow).collect { callback.onNext(it) }
callback.onFinished()
}
}
}
}
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerAttach
*
* @param id ID or name of the container
* @param detachKeys Override the key sequence for detaching a container.Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. (optional)
* @param logs Replay previous logs from the container. This is useful for attaching to a container that has started and you want to output everything since the container started. If `stream` is also enabled, once all the previous output has been returned, it will seamlessly transition into streaming current output. (optional, default to false)
* @param stream Stream attached streams from the time the request was made onwards. (optional, default to false)
* @param stdin Attach to `stdin` (optional, default to false)
* @param stdout Attach to `stdout` (optional, default to false)
* @param stderr Attach to `stderr` (optional, default to false)
* @return RequestConfig
*/
fun containerAttachRequestConfig(
id: String,
detachKeys: String?,
logs: Boolean?,
stream: Boolean?,
stdin: Boolean?,
stdout: Boolean?,
stderr: Boolean?
): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (detachKeys != null) {
put("detachKeys", listOf(detachKeys.toString()))
}
if (logs != null) {
put("logs", listOf(logs.toString()))
}
if (stream != null) {
put("stream", listOf(stream.toString()))
}
if (stdin != null) {
put("stdin", listOf(stdin.toString()))
}
if (stdout != null) {
put("stdout", listOf(stdout.toString()))
}
if (stderr != null) {
put("stderr", listOf(stderr.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/containers/{id}/attach".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Attach to a container via a websocket
*
* @param id ID or name of the container
* @param detachKeys Override the key sequence for detaching a container.Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,`, or `_`. (optional)
* @param logs Return logs (optional, default to false)
* @param stream Return stream (optional, default to false)
* @param stdin Attach to `stdin` (optional, default to false)
* @param stdout Attach to `stdout` (optional, default to false)
* @param stderr Attach to `stderr` (optional, default to false)
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerAttachWebsocket(
id: String,
detachKeys: String?,
logs: Boolean?,
stream: Boolean?,
stdin: Boolean?,
stdout: Boolean?,
stderr: Boolean?
) {
val localVariableConfig = containerAttachWebsocketRequestConfig(id = id, detachKeys = detachKeys, logs = logs, stream = stream, stdin = stdin, stdout = stdout, stderr = stderr)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerAttachWebsocket
*
* @param id ID or name of the container
* @param detachKeys Override the key sequence for detaching a container.Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,`, or `_`. (optional)
* @param logs Return logs (optional, default to false)
* @param stream Return stream (optional, default to false)
* @param stdin Attach to `stdin` (optional, default to false)
* @param stdout Attach to `stdout` (optional, default to false)
* @param stderr Attach to `stderr` (optional, default to false)
* @return RequestConfig
*/
fun containerAttachWebsocketRequestConfig(
id: String,
detachKeys: String?,
logs: Boolean?,
stream: Boolean?,
stdin: Boolean?,
stdout: Boolean?,
stderr: Boolean?
): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (detachKeys != null) {
put("detachKeys", listOf(detachKeys.toString()))
}
if (logs != null) {
put("logs", listOf(logs.toString()))
}
if (stream != null) {
put("stream", listOf(stream.toString()))
}
if (stdin != null) {
put("stdin", listOf(stdin.toString()))
}
if (stdout != null) {
put("stdout", listOf(stdout.toString()))
}
if (stderr != null) {
put("stderr", listOf(stderr.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/containers/{id}/attach/ws".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Get changes on a container’s filesystem
* Returns which files in a container's filesystem have been added, deleted, or modified. The `Kind` of modification can be one of: - `0`: Modified - `1`: Added - `2`: Deleted
* @param id ID or name of the container
* @return kotlin.collections.List
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerChanges(id: String): List {
val localVariableConfig = containerChangesRequestConfig(id = id)
val localVarResponse = request>(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as List
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerChanges
*
* @param id ID or name of the container
* @return RequestConfig
*/
fun containerChangesRequestConfig(id: String): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/containers/{id}/changes".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Create a container
*
* @param body Container to create
* @param name Assign the specified name to the container. Must match `/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`. (optional)
* @return ContainerCreateResponse
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerCreate(body: ContainerCreateRequest, name: String?): ContainerCreateResponse {
val localVariableConfig = containerCreateRequestConfig(body = body, name = name)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ContainerCreateResponse
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerCreate
*
* @param body Container to create
* @param name Assign the specified name to the container. Must match `/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`. (optional)
* @return RequestConfig
*/
fun containerCreateRequestConfig(body: ContainerCreateRequest, name: String?): RequestConfig {
val localVariableBody: Any? = body
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (name != null) {
put("name", listOf(name.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/containers/create",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Remove a container
*
* @param id ID or name of the container
* @param v Remove anonymous volumes associated with the container. (optional, default to false)
* @param force If the container is running, kill it before removing it. (optional, default to false)
* @param link Remove the specified link associated with the container. (optional, default to false)
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerDelete(id: String, v: Boolean?, force: Boolean?, link: Boolean?) {
val localVariableConfig = containerDeleteRequestConfig(id = id, v = v, force = force, link = link)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
if (localVarError.statusCode == HTTP_NOT_FOUND) {
return
}
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerDelete
*
* @param id ID or name of the container
* @param v Remove anonymous volumes associated with the container. (optional, default to false)
* @param force If the container is running, kill it before removing it. (optional, default to false)
* @param link Remove the specified link associated with the container. (optional, default to false)
* @return RequestConfig
*/
fun containerDeleteRequestConfig(id: String, v: Boolean?, force: Boolean?, link: Boolean?): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (v != null) {
put("v", listOf(v.toString()))
}
if (force != null) {
put("force", listOf(force.toString()))
}
if (link != null) {
put("link", listOf(link.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = DELETE,
path = "/containers/{id}".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Export a container
* Export the contents of a container as a tarball.
* @param id ID or name of the container
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerExport(id: String): java.io.File {
val localVariableConfig = containerExportRequestConfig(id = id)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as java.io.File
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerExport
*
* @param id ID or name of the container
* @return RequestConfig
*/
fun containerExportRequestConfig(id: String): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/containers/{id}/export".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Inspect a container
* Return low-level information about a container.
* @param id ID or name of the container
* @param size Return the size of container as fields `SizeRw` and `SizeRootFs` (optional, default to false)
* @return ContainerInspectResponse
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerInspect(id: String, size: Boolean?): ContainerInspectResponse {
val localVariableConfig = containerInspectRequestConfig(id = id, size = size)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ContainerInspectResponse
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerInspect
*
* @param id ID or name of the container
* @param size Return the size of container as fields `SizeRw` and `SizeRootFs` (optional, default to false)
* @return RequestConfig
*/
fun containerInspectRequestConfig(id: String, size: Boolean?): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (size != null) {
put("size", listOf(size.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/containers/{id}/json".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Kill a container
* Send a POSIX signal to a container, defaulting to killing to the container.
* @param id ID or name of the container
* @param signal Signal to send to the container as an integer or string (e.g. `SIGINT`) (optional, default to "SIGKILL")
* @return void
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerKill(id: String, signal: String?) {
val localVariableConfig = containerKillRequestConfig(id = id, signal = signal)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
}
}
/**
* To obtain the request config of the operation containerKill
*
* @param id ID or name of the container
* @param signal Signal to send to the container as an integer or string (e.g. `SIGINT`) (optional, default to "SIGKILL")
* @return RequestConfig
*/
fun containerKillRequestConfig(id: String, signal: String?): RequestConfig {
val localVariableBody: Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (signal != null) {
put("signal", listOf(signal.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/containers/{id}/kill".replace("{" + "id" + "}", id),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* List containers
* Returns a list of containers. For details on the format, see the [inspect endpoint](#operation/ContainerInspect). Note that it uses a different, smaller representation of a container than inspecting a single container. For example, the list of linked containers is not propagated .
* @param all Return all containers. By default, only running containers are shown. (optional, default to false)
* @param limit Return this number of most recently created containers, including non-running ones. (optional)
* @param size Return the size of container as fields `SizeRw` and `SizeRootFs`. (optional, default to false)
* @param filters Filters to process on the container list, encoded as JSON (a `map[string][]string`). For example, `{\"status\": [\"paused\"]}` will only return paused containers. Available filters: - `ancestor`=(`<image-name>[:<tag>]`, `<image id>`, or `<image@digest>`) - `before`=(`<container id>` or `<container name>`) - `expose`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`) - `exited=<int>` containers with exit code of `<int>` - `health`=(`starting`|`healthy`|`unhealthy`|`none`) - `id=<ID>` a container's ID - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only) - `is-task=`(`true`|`false`) - `label=key` or `label=\"key=value\"` of a container label - `name=<name>` a container's name - `network`=(`<network id>` or `<network name>`) - `publish`=(`<port>[/<proto>]`|`<startport-endport>/[<proto>]`) - `since`=(`<container id>` or `<container name>`) - `status=`(`created`|`restarting`|`running`|`removing`|`paused`|`exited`|`dead`) - `volume`=(`<volume name>` or `<mount point destination>`) (optional)
* @return kotlin.collections.List
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun containerList(all: Boolean?, limit: Int?, size: Boolean?, filters: String?): List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy