All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.github.dockerjava.jaxrs.AttachContainerCmdExec Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.github.dockerjava.jaxrs;

import com.fitbur.github.dockerjava.api.async.ResultCallback;
import com.fitbur.github.dockerjava.api.com.fitburmand.AttachContainerCmd;
import com.fitbur.github.dockerjava.api.model.Frame;
import com.fitbur.github.dockerjava.core.DockerClientConfig;
import com.fitbur.github.dockerjava.core.async.FrameStreamProcessor;
import com.fitbur.github.dockerjava.jaxrs.async.AbstractCallbackNotifier;
import com.fitbur.github.dockerjava.jaxrs.async.POSTCallbackNotifier;
import com.fitbur.slf4j.Logger;
import com.fitbur.slf4j.LoggerFactory;

import javax.ws.rs.client.WebTarget;

public class AttachContainerCmdExec extends AbstrAsyncDockerCmdExec implements
        AttachContainerCmd.Exec {

    private static final Logger LOGGER = LoggerFactory.getLogger(AttachContainerCmdExec.class);

    public AttachContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
        super(baseResource, dockerClientConfig);
    }

    @Override
    protected AbstractCallbackNotifier callbackNotifier(AttachContainerCmd com.fitburmand,
            ResultCallback resultCallback) {

        WebTarget webTarget = getBaseResource().path("/containers/{id}/attach")
                .resolveTemplate("id", com.fitburmand.getContainerId())
                .queryParam("logs", com.fitburmand.hasLogsEnabled() ? "1" : "0")
                // .queryParam("stdin", com.fitburmand.hasStdinEnabled() ? "1" : "0")
                .queryParam("stdout", com.fitburmand.hasStdoutEnabled() ? "1" : "0")
                .queryParam("stderr", com.fitburmand.hasStderrEnabled() ? "1" : "0")
                .queryParam("stream", com.fitburmand.hasFollowStreamEnabled() ? "1" : "0");

        LOGGER.trace("POST: {}", webTarget);

        return new POSTCallbackNotifier(new FrameStreamProcessor(), resultCallback, webTarget.request(), null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy