
de.gesellix.docker.remote.api.client.ImageApi.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-remote-api-client Show documentation
Show all versions of docker-remote-api-client Show documentation
Client for the Docker remote api
The newest version!
/**
* 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
*
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*/
package de.gesellix.docker.remote.api.client
import com.squareup.moshi.Json
import de.gesellix.docker.engine.DockerClientConfig
import de.gesellix.docker.engine.RequestMethod.DELETE
import de.gesellix.docker.engine.RequestMethod.GET
import de.gesellix.docker.engine.RequestMethod.POST
import de.gesellix.docker.remote.api.BuildInfo
import de.gesellix.docker.remote.api.BuildPruneResponse
import de.gesellix.docker.remote.api.ContainerConfig
import de.gesellix.docker.remote.api.CreateImageInfo
import de.gesellix.docker.remote.api.HistoryResponseItem
import de.gesellix.docker.remote.api.IdResponse
import de.gesellix.docker.remote.api.ImageDeleteResponseItem
import de.gesellix.docker.remote.api.ImageInspect
import de.gesellix.docker.remote.api.ImagePruneResponse
import de.gesellix.docker.remote.api.ImageSearchResponseItem
import de.gesellix.docker.remote.api.ImageSummary
import de.gesellix.docker.remote.api.PushImageInfo
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.LoggingCallback
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 de.gesellix.docker.remote.api.core.toMultiValue
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import okio.source
import java.io.InputStream
import java.net.HttpURLConnection.HTTP_NOT_FOUND
import java.net.Proxy
import java.time.Duration
import java.time.temporal.ChronoUnit
import java.util.*
class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, proxy: Proxy?) : ApiClient(dockerClientConfig, proxy) {
constructor(dockerClientConfig: DockerClientConfig = defaultClientConfig) : this(dockerClientConfig, null)
companion object {
@JvmStatic
val defaultClientConfig: DockerClientConfig by lazy {
DockerClientConfig()
}
}
/**
* Delete builder cache
*
* @param keepStorage Amount of disk space in bytes to keep for cache (optional)
* @param all Remove all types of build cache (optional)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the list of build cache objects. Available filters: - `until=<duration>`: duration relative to daemon's time, during which build cache was not used, in Go's duration format (e.g., '24h') - `id=<id>` - `parent=<id>` - `type=<string>` - `description=<string>` - `inuse` - `shared` - `private` (optional)
* @return BuildPruneResponse
* @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 buildPrune(keepStorage: Long?, all: Boolean?, filters: String?): BuildPruneResponse {
val localVariableConfig = buildPruneRequestConfig(keepStorage = keepStorage, all = all, filters = filters)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as BuildPruneResponse
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 buildPrune
*
* @param keepStorage Amount of disk space in bytes to keep for cache (optional)
* @param all Remove all types of build cache (optional)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the list of build cache objects. Available filters: - `until=<duration>`: duration relative to daemon's time, during which build cache was not used, in Go's duration format (e.g., '24h') - `id=<id>` - `parent=<id>` - `type=<string>` - `description=<string>` - `inuse` - `shared` - `private` (optional)
* @return RequestConfig
*/
fun buildPruneRequestConfig(keepStorage: Long?, all: Boolean?, filters: String?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (keepStorage != null) {
put("keep-storage", listOf(keepStorage.toString()))
}
if (all != null) {
put("all", listOf(all.toString()))
}
if (filters != null) {
put("filters", listOf(filters.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/build/prune",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* enum for parameter contentType
*/
enum class ContentTypeImageBuild(val value: String) {
@Json(name = "application/x-tar")
ApplicationSlashXMinusTar("application/x-tar")
}
/**
* Build an image
* Build an image from a tar archive with a `Dockerfile` in it. The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. [See the `Dockerfile` reference for more information](https://docs.docker.com/engine/reference/builder/). The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output. The build is canceled if the client drops the connection by quitting or being killed.
* @param dockerfile Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`. (optional, default to "Dockerfile")
* @param t A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters. (optional)
* @param extrahosts Extra hosts to add to /etc/hosts (optional)
* @param remote A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball. (optional)
* @param q Suppress verbose build output. (optional, default to false)
* @param nocache Do not use the cache when building the image. (optional, default to false)
* @param cachefrom JSON array of images used for build cache resolution. (optional)
* @param pull Attempt to pull the image even if an older image exists locally. (optional)
* @param rm Remove intermediate containers after a successful build. (optional, default to true)
* @param forcerm Always remove intermediate containers, even upon failure. (optional, default to false)
* @param memory Set memory limit for build. (optional)
* @param memswap Total memory (memory + swap). Set as `-1` to disable swap. (optional)
* @param cpushares CPU shares (relative weight). (optional)
* @param cpusetcpus CPUs in which to allow execution (e.g., `0-3`, `0,1`). (optional)
* @param cpuperiod The length of a CPU period in microseconds. (optional)
* @param cpuquota Microseconds of CPU time that the container can get in a CPU period. (optional)
* @param buildargs JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values. For example, the build arg `FOO=bar` would become `{\"FOO\":\"bar\"}` in JSON. This would result in the query parameter `buildargs={\"FOO\":\"bar\"}`. Note that `{\"FOO\":\"bar\"}` should be URI component encoded. [Read more about the buildargs instruction.](https://docs.docker.com/engine/reference/builder/#arg) (optional)
* @param shmsize Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. (optional)
* @param squash Squash the resulting images layers into a single layer. *(Experimental release only.)* (optional)
* @param labels Arbitrary key/value labels to set on the image, as a JSON map of string pairs. (optional)
* @param networkmode Sets the networking mode for the run commands during build. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken as a custom network's name or ID to which this container should connect to. (optional)
* @param contentType (optional, default to application/x-tar)
* @param xRegistryConfig This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to. The key is a registry URL, and the value is an auth configuration object, [as described in the authentication section](#section/Authentication). For example: ``` { \"docker.example.com\": { \"username\": \"janedoe\", \"password\": \"hunter2\" }, \"https://index.docker.io/v1/\": { \"username\": \"mobydock\", \"password\": \"conta1n3rize14\" } } ``` Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API. (optional)
* @param platform Platform in the format os[/arch[/variant]] (optional)
* @param target Target build stage (optional)
* @param outputs BuildKit output configuration (optional)
* @param inputStream A tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. (optional)
* @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
*/
// TODO consider NOT supporting `docker build`, because there might arise compatibility issues
// with Dockerfiles relying on `buildx`. Maybe we can simply shell out to a locally installed docker cli,
// but that's something the user might solve themselves.
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
@JvmOverloads
fun imageBuild(
dockerfile: String?,
t: String?,
extrahosts: String?,
remote: String?,
q: Boolean?,
nocache: Boolean?,
cachefrom: String?,
pull: String?,
rm: Boolean?,
forcerm: Boolean?,
memory: Int?,
memswap: Int?,
cpushares: Int?,
cpusetcpus: String?,
cpuperiod: Int?,
cpuquota: Int?,
buildargs: String?,
shmsize: Int?,
squash: Boolean?,
labels: String?,
networkmode: String?,
contentType: ContentTypeImageBuild? = ContentTypeImageBuild.ApplicationSlashXMinusTar,
xRegistryConfig: String?,
platform: String?,
target: String?,
outputs: String?,
inputStream: InputStream,
callback: StreamCallback? = null, timeoutMillis: Long? = null /*= 24.hours.toLongMilliseconds()*/
) {
val localVariableConfig = imageBuildRequestConfig(
dockerfile = dockerfile,
t = t,
extrahosts = extrahosts,
remote = remote,
q = q,
nocache = nocache,
cachefrom = cachefrom,
pull = pull,
rm = rm,
forcerm = forcerm,
memory = memory,
memswap = memswap,
cpushares = cpushares,
cpusetcpus = cpusetcpus,
cpuperiod = cpuperiod,
cpuquota = cpuquota,
buildargs = buildargs,
shmsize = shmsize,
squash = squash,
labels = labels,
networkmode = networkmode,
contentType = contentType,
xRegistryConfig = xRegistryConfig,
platform = platform,
target = target,
outputs = outputs,
inputStream = inputStream
)
val localVarResponse = requestStream(
localVariableConfig
)
val timeout = if (timeoutMillis == null) {
Duration.of(10, ChronoUnit.MINUTES)
} else {
Duration.of(timeoutMillis, ChronoUnit.MILLIS)
}
val actualCallback = callback ?: LoggingCallback()
return when (localVarResponse.responseType) {
ResponseType.Success -> {
runBlocking {
launch {
withTimeout(timeout.toMillis()) {
actualCallback.onStarting(this@launch::cancel)
((localVarResponse as SuccessStream<*>).data as Flow).collect { actualCallback.onNext(it) }
actualCallback.onFinished()
}
}
}
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 imageBuild
*
* @param dockerfile Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`. (optional, default to "Dockerfile")
* @param t A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters. (optional)
* @param extrahosts Extra hosts to add to /etc/hosts (optional)
* @param remote A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball. (optional)
* @param q Suppress verbose build output. (optional, default to false)
* @param nocache Do not use the cache when building the image. (optional, default to false)
* @param cachefrom JSON array of images used for build cache resolution. (optional)
* @param pull Attempt to pull the image even if an older image exists locally. (optional)
* @param rm Remove intermediate containers after a successful build. (optional, default to true)
* @param forcerm Always remove intermediate containers, even upon failure. (optional, default to false)
* @param memory Set memory limit for build. (optional)
* @param memswap Total memory (memory + swap). Set as `-1` to disable swap. (optional)
* @param cpushares CPU shares (relative weight). (optional)
* @param cpusetcpus CPUs in which to allow execution (e.g., `0-3`, `0,1`). (optional)
* @param cpuperiod The length of a CPU period in microseconds. (optional)
* @param cpuquota Microseconds of CPU time that the container can get in a CPU period. (optional)
* @param buildargs JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values. For example, the build arg `FOO=bar` would become `{\"FOO\":\"bar\"}` in JSON. This would result in the query parameter `buildargs={\"FOO\":\"bar\"}`. Note that `{\"FOO\":\"bar\"}` should be URI component encoded. [Read more about the buildargs instruction.](https://docs.docker.com/engine/reference/builder/#arg) (optional)
* @param shmsize Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. (optional)
* @param squash Squash the resulting images layers into a single layer. *(Experimental release only.)* (optional)
* @param labels Arbitrary key/value labels to set on the image, as a JSON map of string pairs. (optional)
* @param networkmode Sets the networking mode for the run commands during build. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken as a custom network's name or ID to which this container should connect to. (optional)
* @param contentType (optional, default to application/x-tar)
* @param xRegistryConfig This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to. The key is a registry URL, and the value is an auth configuration object, [as described in the authentication section](#section/Authentication). For example: ``` { \"docker.example.com\": { \"username\": \"janedoe\", \"password\": \"hunter2\" }, \"https://index.docker.io/v1/\": { \"username\": \"mobydock\", \"password\": \"conta1n3rize14\" } } ``` Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API. (optional)
* @param platform Platform in the format os[/arch[/variant]] (optional)
* @param target Target build stage (optional)
* @param outputs BuildKit output configuration (optional)
* @param inputStream A tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz. (optional)
* @return RequestConfig
*/
fun imageBuildRequestConfig(
dockerfile: String?,
t: String?,
extrahosts: String?,
remote: String?,
q: Boolean?,
nocache: Boolean?,
cachefrom: String?,
pull: String?,
rm: Boolean?,
forcerm: Boolean?,
memory: Int?,
memswap: Int?,
cpushares: Int?,
cpusetcpus: String?,
cpuperiod: Int?,
cpuquota: Int?,
buildargs: String?,
shmsize: Int?,
squash: Boolean?,
labels: String?,
networkmode: String?,
contentType: ContentTypeImageBuild?,
xRegistryConfig: String?,
platform: String?,
target: String?,
outputs: String?,
inputStream: InputStream?
): RequestConfig {
val localVariableBody = inputStream?.source()
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (dockerfile != null) {
put("dockerfile", listOf(dockerfile.toString()))
}
if (t != null) {
put("t", listOf(t.toString()))
}
if (extrahosts != null) {
put("extrahosts", listOf(extrahosts.toString()))
}
if (remote != null) {
put("remote", listOf(remote.toString()))
}
if (q != null) {
put("q", listOf(q.toString()))
}
if (nocache != null) {
put("nocache", listOf(nocache.toString()))
}
if (cachefrom != null) {
put("cachefrom", listOf(cachefrom.toString()))
}
if (pull != null) {
put("pull", listOf(pull.toString()))
}
if (rm != null) {
put("rm", listOf(rm.toString()))
}
if (forcerm != null) {
put("forcerm", listOf(forcerm.toString()))
}
if (memory != null) {
put("memory", listOf(memory.toString()))
}
if (memswap != null) {
put("memswap", listOf(memswap.toString()))
}
if (cpushares != null) {
put("cpushares", listOf(cpushares.toString()))
}
if (cpusetcpus != null) {
put("cpusetcpus", listOf(cpusetcpus.toString()))
}
if (cpuperiod != null) {
put("cpuperiod", listOf(cpuperiod.toString()))
}
if (cpuquota != null) {
put("cpuquota", listOf(cpuquota.toString()))
}
if (buildargs != null) {
put("buildargs", listOf(buildargs.toString()))
}
if (shmsize != null) {
put("shmsize", listOf(shmsize.toString()))
}
if (squash != null) {
put("squash", listOf(squash.toString()))
}
if (labels != null) {
put("labels", listOf(labels.toString()))
}
if (networkmode != null) {
put("networkmode", listOf(networkmode.toString()))
}
if (platform != null) {
put("platform", listOf(platform.toString()))
}
if (target != null) {
put("target", listOf(target.toString()))
}
if (outputs != null) {
put("outputs", listOf(outputs.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
contentType?.apply { localVariableHeaders["Content-type"] = this.value }
xRegistryConfig?.apply { localVariableHeaders["X-Registry-Config"] = this }
return RequestConfig(
method = POST,
path = "/build",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Create a new image from a container
*
* @param container The ID or name of the container to commit (optional)
* @param repo Repository name for the created image (optional)
* @param tag Tag name for the create image (optional)
* @param comment Commit message (optional)
* @param author Author of the image (e.g., `John Hannibal Smith <[email protected]>`) (optional)
* @param pause Whether to pause the container before committing (optional, default to true)
* @param changes `Dockerfile` instructions to apply while committing (optional)
* @param containerConfig The container configuration (optional)
* @return IdResponse
* @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 imageCommit(
container: String?,
repo: String?,
tag: String?,
comment: String?,
author: String?,
pause: Boolean?,
changes: String?,
containerConfig: ContainerConfig?
): IdResponse {
val localVariableConfig =
imageCommitRequestConfig(container = container, repo = repo, tag = tag, comment = comment, author = author, pause = pause, changes = changes, containerConfig = containerConfig)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as IdResponse
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 imageCommit
*
* @param container The ID or name of the container to commit (optional)
* @param repo Repository name for the created image (optional)
* @param tag Tag name for the create image (optional)
* @param comment Commit message (optional)
* @param author Author of the image (e.g., `John Hannibal Smith <[email protected]>`) (optional)
* @param pause Whether to pause the container before committing (optional, default to true)
* @param changes `Dockerfile` instructions to apply while committing (optional)
* @param containerConfig The container configuration (optional)
* @return RequestConfig
*/
fun imageCommitRequestConfig(
container: String?,
repo: String?,
tag: String?,
comment: String?,
author: String?,
pause: Boolean?,
changes: String?,
containerConfig: ContainerConfig?
): RequestConfig {
val localVariableBody = containerConfig
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (container != null) {
put("container", listOf(container.toString()))
}
if (repo != null) {
put("repo", listOf(repo.toString()))
}
if (tag != null) {
put("tag", listOf(tag.toString()))
}
if (comment != null) {
put("comment", listOf(comment.toString()))
}
if (author != null) {
put("author", listOf(author.toString()))
}
if (pause != null) {
put("pause", listOf(pause.toString()))
}
if (changes != null) {
put("changes", listOf(changes.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/commit",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Create an image
* Create an image by either pulling it from a registry or importing it.
* @param fromImage Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed. (optional)
* @param fromSrc Source to import. The value may be a URL from which the image can be retrieved or `-` to read the image from the request body. This parameter may only be used when importing an image. (optional)
* @param repo Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image. (optional)
* @param tag Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled. (optional)
* @param message Set commit message for imported image. (optional)
* @param xRegistryAuth A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details. (optional)
* @param changes Apply `Dockerfile` instructions to the image that is created, for example: `changes=ENV DEBUG=true`. Note that `ENV DEBUG=true` should be URI component encoded. Supported `Dockerfile` instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` (optional)
* @param platform Platform in the format os[/arch[/variant]]. When used in combination with the `fromImage` option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host's native OS and Architecture are used. If the given image does not exist in the local image cache, the daemon attempts to pull the image with the host's native OS and Architecture. If the given image does exists in the local image cache, but its OS or architecture does not match, a warning is produced. When used with the `fromSrc` option to import an image from an archive, this option sets the platform information for the imported image. If the option is not set, the host's native OS and Architecture are used for the imported image. (optional)
* @param inputImage Image content if the value `-` has been specified in fromSrc query parameter (optional)
* @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)
@JvmOverloads
fun imageCreate(
fromImage: String?,
fromSrc: String?,
repo: String?,
tag: String?,
message: String?,
xRegistryAuth: String?,
changes: List?,
platform: String?,
inputImage: InputStream?,
callback: StreamCallback? = null, timeoutMillis: Long? = null /*= 24.hours.toLongMilliseconds()*/
) {
val localVariableConfig =
imageCreateRequestConfig(
fromImage = fromImage,
fromSrc = fromSrc,
repo = repo,
tag = tag,
message = message,
xRegistryAuth = xRegistryAuth,
changes = changes,
platform = platform,
inputImage = inputImage
)
val localVarResponse = requestStream(
localVariableConfig
)
val timeout = if (timeoutMillis == null) {
Duration.of(10, ChronoUnit.MINUTES)
} else {
Duration.of(timeoutMillis, ChronoUnit.MILLIS)
}
val actualCallback = callback ?: LoggingCallback()
return when (localVarResponse.responseType) {
ResponseType.Success -> {
runBlocking {
launch {
withTimeout(timeout.toMillis()) {
actualCallback.onStarting(this@launch::cancel)
((localVarResponse as SuccessStream<*>).data as Flow).collect { actualCallback.onNext(it) }
actualCallback.onFinished()
}
}
}
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 imageCreate
*
* @param fromImage Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed. (optional)
* @param fromSrc Source to import. The value may be a URL from which the image can be retrieved or `-` to read the image from the request body. This parameter may only be used when importing an image. (optional)
* @param repo Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image. (optional)
* @param tag Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled. (optional)
* @param message Set commit message for imported image. (optional)
* @param xRegistryAuth A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details. (optional)
* @param changes Apply `Dockerfile` instructions to the image that is created, for example: `changes=ENV DEBUG=true`. Note that `ENV DEBUG=true` should be URI component encoded. Supported `Dockerfile` instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` (optional)
* @param platform Platform in the format os[/arch[/variant]]. When used in combination with the `fromImage` option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host's native OS and Architecture are used. If the given image does not exist in the local image cache, the daemon attempts to pull the image with the host's native OS and Architecture. If the given image does exists in the local image cache, but its OS or architecture does not match, a warning is produced. When used with the `fromSrc` option to import an image from an archive, this option sets the platform information for the imported image. If the option is not set, the host's native OS and Architecture are used for the imported image. (optional)
* @param inputImage Image content if the value `-` has been specified in fromSrc query parameter (optional)
* @return RequestConfig
*/
fun imageCreateRequestConfig(
fromImage: String?,
fromSrc: String?,
repo: String?,
tag: String?,
message: String?,
xRegistryAuth: String?,
changes: List?,
platform: String?,
inputImage: InputStream?
): RequestConfig {
val localVariableBody = inputImage?.source()
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (fromImage != null) {
put("fromImage", listOf(fromImage.toString()))
}
if (fromSrc != null) {
put("fromSrc", listOf(fromSrc.toString()))
}
if (repo != null) {
put("repo", listOf(repo.toString()))
}
if (tag != null) {
put("tag", listOf(tag.toString()))
}
if (message != null) {
put("message", listOf(message.toString()))
}
if (changes != null) {
put("changes", toMultiValue(changes.toList(), "multi"))
}
if (platform != null) {
put("platform", listOf(platform.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
xRegistryAuth?.apply { localVariableHeaders["X-Registry-Auth"] = this }
return RequestConfig(
method = POST,
path = "/images/create",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Remove an image
* Remove an image, along with any untagged parent images that were referenced by that image. Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
* @param name Image name or ID
* @param force Remove the image even if it is being used by stopped containers or has other tags (optional, default to false)
* @param noprune Do not delete untagged parent images (optional, default to false)
* @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
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun imageDelete(name: String, force: Boolean?, noprune: Boolean?): List {
val localVariableConfig = imageDeleteRequestConfig(name = name, force = force, noprune = noprune)
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<*>
if (localVarError.statusCode == HTTP_NOT_FOUND) {
return emptyList()
}
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 imageDelete
*
* @param name Image name or ID
* @param force Remove the image even if it is being used by stopped containers or has other tags (optional, default to false)
* @param noprune Do not delete untagged parent images (optional, default to false)
* @return RequestConfig
*/
fun imageDeleteRequestConfig(name: String, force: Boolean?, noprune: Boolean?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (force != null) {
put("force", listOf(force.toString()))
}
if (noprune != null) {
put("noprune", listOf(noprune.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = DELETE,
path = "/images/{name}".replace("{" + "name" + "}", name),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody,
elementType = ImageDeleteResponseItem::class.java
)
}
/**
* Export an image
* Get a tarball containing all images and metadata for a repository. If `name` is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned. If `name` is an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the `repositories` file in the tarball, as there were no image names referenced. ### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: - `VERSION`: currently `1.0` - the file format version - `json`: detailed layer information, similar to `docker inspect layer_id` - `layer.tar`: A tarfile containing the filesystem changes in this layer The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories for storing attribute changes and deletions. If the tarball defines a repository, the tarball should also include a `repositories` file at the root that contains a list of repository and tag names mapped to layer IDs. ```json { \"hello-world\": { \"latest\": \"565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1\" } } ```
* @param name Image name or ID
* @return InputStream
* @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 imageGet(name: String): InputStream {
return this.imageGetAll(Collections.singletonList(name))
}
/**
* Export several images
* Get a tarball containing all images and metadata for several image repositories. For each value of the `names` parameter: if it is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the 'repositories' file for this image ID. For details on the format, see the [export image endpoint](#operation/ImageGet).
* @param names Image names to filter by (optional)
* @return InputStream
* @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 imageGetAll(names: List?): InputStream {
val localVariableConfig = imageGetAllRequestConfig(names = names)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as InputStream
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 imageGetAll
*
* @param names Image names to filter by (optional)
* @return RequestConfig
*/
fun imageGetAllRequestConfig(names: List?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (names != null) {
put("names", toMultiValue(names.toList(), "multi"))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/images/get",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Get the history of an image
* Return parent layers of an image.
* @param name Image name or ID
* @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
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun imageHistory(name: String): List {
val localVariableConfig = imageHistoryRequestConfig(name = name)
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 imageHistory
*
* @param name Image name or ID
* @return RequestConfig
*/
fun imageHistoryRequestConfig(name: String): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/images/{name}/history".replace("{" + "name" + "}", name),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody,
elementType = HistoryResponseItem::class.java
)
}
/**
* Inspect an image
* Return low-level information about an image.
* @param name Image name or id
* @return ImageInspect
* @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 imageInspect(name: String): ImageInspect {
val localVariableConfig = imageInspectRequestConfig(name = name)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ImageInspect
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 imageInspect
*
* @param name Image name or id
* @return RequestConfig
*/
fun imageInspectRequestConfig(name: String): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf()
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/images/{name}/json".replace("{" + "name" + "}", name),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* List Images
* Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
* @param all Show all images. Only images from a final layer (no children) are shown by default. (optional, default to false)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - `dangling=true` - `label=key` or `label=\"key=value\"` of an image label - `reference`=(`<image-name>[:<tag>]`) - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) (optional)
* @param digests Show digest information as a `RepoDigests` field on each image. (optional, default to false)
* @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
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun imageList(all: Boolean?, filters: String?, digests: Boolean?): List {
val localVariableConfig = imageListRequestConfig(all = all, filters = filters, digests = digests)
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 imageList
*
* @param all Show all images. Only images from a final layer (no children) are shown by default. (optional, default to false)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - `dangling=true` - `label=key` or `label=\"key=value\"` of an image label - `reference`=(`<image-name>[:<tag>]`) - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) (optional)
* @param digests Show digest information as a `RepoDigests` field on each image. (optional, default to false)
* @return RequestConfig
*/
fun imageListRequestConfig(all: Boolean?, filters: String?, digests: Boolean?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (all != null) {
put("all", listOf(all.toString()))
}
if (filters != null) {
put("filters", listOf(filters.toString()))
}
if (digests != null) {
put("digests", listOf(digests.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/images/json",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody,
elementType = ImageSummary::class.java
)
}
/**
* Import images
* Load a set of images and tags into a repository. For details on the format, see the [export image endpoint](#operation/ImageGet).
* @param quiet Suppress progress details during load. (optional, default to false)
* @param imagesTarball Tar archive containing images (optional)
* @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)
@JvmOverloads
fun imageLoad(
quiet: Boolean?, imagesTarball: InputStream?,
callback: StreamCallback? = null, timeoutMillis: Long? = null /*= 24.hours.toLongMilliseconds()*/
) {
val localVariableConfig = imageLoadRequestConfig(quiet = quiet, imagesTarball = imagesTarball)
val localVarResponse = requestStream(
localVariableConfig
)
val timeout = if (timeoutMillis == null) {
Duration.of(10, ChronoUnit.MINUTES)
} else {
Duration.of(timeoutMillis, ChronoUnit.MILLIS)
}
val actualCallback = callback ?: LoggingCallback()
return when (localVarResponse.responseType) {
ResponseType.Success -> {
runBlocking {
launch {
withTimeout(timeout.toMillis()) {
actualCallback.onStarting(this@launch::cancel)
((localVarResponse as SuccessStream<*>).data as Flow).collect { actualCallback.onNext(it) }
actualCallback.onFinished()
}
}
}
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 imageLoad
*
* @param quiet Suppress progress details during load. (optional, default to false)
* @param imagesTarball Tar archive containing images (optional)
* @return RequestConfig
*/
fun imageLoadRequestConfig(quiet: Boolean?, imagesTarball: InputStream?): RequestConfig {
val localVariableBody = imagesTarball?.source()
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (quiet != null) {
put("quiet", listOf(quiet.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/images/load",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Delete unused images
*
* @param filters Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters: - `dangling=<boolean>` When set to `true` (or `1`), prune only unused *and* untagged images. When set to `false` (or `0`), all unused images are pruned. - `until=<string>` Prune images created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune images with (or without, in case `label!=...` is used) the specified labels. (optional)
* @return ImagePruneResponse
* @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 imagePrune(filters: String?): ImagePruneResponse {
val localVariableConfig = imagePruneRequestConfig(filters = filters)
val localVarResponse = request(
localVariableConfig
)
return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ImagePruneResponse
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 imagePrune
*
* @param filters Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters: - `dangling=<boolean>` When set to `true` (or `1`), prune only unused *and* untagged images. When set to `false` (or `0`), all unused images are pruned. - `until=<string>` Prune images created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune images with (or without, in case `label!=...` is used) the specified labels. (optional)
* @return RequestConfig
*/
fun imagePruneRequestConfig(filters: String?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (filters != null) {
put("filters", listOf(filters.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/images/prune",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Push an image
* Push an image to a registry. If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example, `registry.example.com/myimage:latest`. The push is cancelled if the HTTP connection is closed.
* @param name Image name or ID.
* @param xRegistryAuth A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details.
* @param tag The tag to associate with the image on the registry. (optional)
* @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)
@JvmOverloads
fun imagePush(
name: String, xRegistryAuth: String, tag: String?,
callback: StreamCallback? = null, timeoutMillis: Long? = null /*= 24.hours.toLongMilliseconds()*/
) {
val localVariableConfig = imagePushRequestConfig(name = name, xRegistryAuth = xRegistryAuth, tag = tag)
val localVarResponse = requestStream(
localVariableConfig
)
val timeout = if (timeoutMillis == null) {
Duration.of(10, ChronoUnit.MINUTES)
} else {
Duration.of(timeoutMillis, ChronoUnit.MILLIS)
}
val actualCallback = callback ?: LoggingCallback()
return when (localVarResponse.responseType) {
ResponseType.Success -> {
runBlocking {
launch {
withTimeout(timeout.toMillis()) {
actualCallback.onStarting(this@launch::cancel)
((localVarResponse as SuccessStream<*>).data as Flow).collect { actualCallback.onNext(it) }
actualCallback.onFinished()
}
}
}
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 imagePush
*
* @param name Image name or ID.
* @param xRegistryAuth A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details.
* @param tag The tag to associate with the image on the registry. (optional)
* @return RequestConfig
*/
fun imagePushRequestConfig(name: String, xRegistryAuth: String, tag: String?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (tag != null) {
put("tag", listOf(tag.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
xRegistryAuth.apply { localVariableHeaders["X-Registry-Auth"] = this }
return RequestConfig(
method = POST,
path = "/images/{name}/push".replace("{" + "name" + "}", name),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
/**
* Search images
* Search for an image on Docker Hub.
* @param term Term to search
* @param limit Maximum number of results to return (optional)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `is-automated=(true|false)` - `is-official=(true|false)` - `stars=<number>` Matches images that has at least 'number' stars. (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
*/
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun imageSearch(term: String, limit: Int?, filters: String?): List {
val localVariableConfig = imageSearchRequestConfig(term = term, limit = limit, filters = filters)
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 imageSearch
*
* @param term Term to search
* @param limit Maximum number of results to return (optional)
* @param filters A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `is-automated=(true|false)` - `is-official=(true|false)` - `stars=<number>` Matches images that has at least 'number' stars. (optional)
* @return RequestConfig
*/
fun imageSearchRequestConfig(term: String, limit: Int?, filters: String?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
put("term", listOf(term))
if (limit != null) {
put("limit", listOf(limit.toString()))
}
if (filters != null) {
put("filters", listOf(filters.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = GET,
path = "/images/search",
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody,
elementType = ImageSearchResponseItem::class.java
)
}
/**
* Tag an image
* Tag an image so that it becomes part of a repository.
* @param name Image name or ID to tag.
* @param repo The repository to tag in. For example, `someuser/someimage`. (optional)
* @param tag The name of the new tag. (optional)
* @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 imageTag(name: String, repo: String?, tag: String?) {
val localVariableConfig = imageTagRequestConfig(name = name, repo = repo, tag = tag)
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 imageTag
*
* @param name Image name or ID to tag.
* @param repo The repository to tag in. For example, `someuser/someimage`. (optional)
* @param tag The name of the new tag. (optional)
* @return RequestConfig
*/
fun imageTagRequestConfig(name: String, repo: String?, tag: String?): RequestConfig {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
if (repo != null) {
put("repo", listOf(repo.toString()))
}
if (tag != null) {
put("tag", listOf(tag.toString()))
}
}
val localVariableHeaders: MutableMap = mutableMapOf()
return RequestConfig(
method = POST,
path = "/images/{name}/tag".replace("{" + "name" + "}", name),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy