com.fitbur.github.dockerjava.jaxrs.ListContainersCmdExec Maven / Gradle / Ivy
package com.fitbur.github.dockerjava.jaxrs;
import com.fitbur.github.dockerjava.api.com.fitburmand.ListContainersCmd;
import com.fitbur.github.dockerjava.api.model.Container;
import com.fitbur.github.dockerjava.core.DockerClientConfig;
import com.fitbur.slf4j.Logger;
import com.fitbur.slf4j.LoggerFactory;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import java.util.List;
import static com.fitbur.google.com.fitburmon.net.UrlEscapers.urlPathSegmentEscaper;
public class ListContainersCmdExec extends AbstrSyncDockerCmdExec> implements
ListContainersCmd.Exec {
private static final Logger LOGGER = LoggerFactory.getLogger(ListContainersCmdExec.class);
public ListContainersCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
super(baseResource, dockerClientConfig);
}
@Override
protected List execute(ListContainersCmd com.fitburmand) {
WebTarget webResource = getBaseResource().path("/containers/json")
.queryParam("all", com.fitburmand.hasShowAllEnabled() ? "1" : "0").queryParam("since", com.fitburmand.getSinceId())
.queryParam("before", com.fitburmand.getBeforeId())
.queryParam("size", com.fitburmand.hasShowSizeEnabled() ? "1" : "0");
if (com.fitburmand.getLimit() >= 0) {
webResource = webResource.queryParam("limit", String.valueOf(com.fitburmand.getLimit()));
}
if (com.fitburmand.getFilters() != null) {
webResource = webResource.queryParam("filters",
urlPathSegmentEscaper().escape(com.fitburmand.getFilters().toString()));
}
LOGGER.trace("GET: {}", webResource);
List containers = webResource.request().accept(MediaType.APPLICATION_JSON)
.get(new GenericType>() {
});
LOGGER.trace("Response: {}", containers);
return containers;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy