use of com.spotify.docker.client.exceptions.UnsupportedApiVersionException in project docker-client by spotify.
the class DefaultDockerClient method archiveContainer.
@Override
public InputStream archiveContainer(String containerId, String path) throws DockerException, InterruptedException {
final String apiVersion = version().apiVersion();
final int versionComparison = compareVersion(apiVersion, "1.20");
// Version below 1.20
if (versionComparison < 0) {
throw new UnsupportedApiVersionException(apiVersion);
}
final WebTarget resource = resource().path("containers").path(containerId).path("archive").queryParam("path", path);
try {
return request(GET, InputStream.class, resource, resource.request(APPLICATION_OCTET_STREAM_TYPE));
} catch (DockerRequestException e) {
switch(e.status()) {
case 404:
throw new ContainerNotFoundException(containerId, e);
default:
throw e;
}
}
}
use of com.spotify.docker.client.exceptions.UnsupportedApiVersionException in project docker-client by spotify.
the class DefaultDockerClient method copyContainer.
@Override
@Deprecated
public InputStream copyContainer(String containerId, String path) throws DockerException, InterruptedException {
final String apiVersion = version().apiVersion();
final int versionComparison = compareVersion(apiVersion, "1.24");
// Version above 1.24
if (versionComparison >= 0) {
throw new UnsupportedApiVersionException(apiVersion);
}
final WebTarget resource = resource().path("containers").path(containerId).path("copy");
// Internal JSON object; not worth it to create class for this
final JsonNodeFactory nf = JsonNodeFactory.instance;
final JsonNode params = nf.objectNode().set("Resource", nf.textNode(path));
try {
return request(POST, InputStream.class, resource, resource.request(APPLICATION_OCTET_STREAM_TYPE), Entity.json(params));
} catch (DockerRequestException e) {
switch(e.status()) {
case 404:
throw new ContainerNotFoundException(containerId, e);
default:
throw e;
}
}
}
Aggregations