Search in sources :

Example 1 with NodeNotFoundException

use of com.spotify.docker.client.exceptions.NodeNotFoundException in project docker-client by spotify.

the class DefaultDockerClient method inspectNode.

@Override
public NodeInfo inspectNode(final String nodeId) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    WebTarget resource = resource().path("nodes").path(nodeId);
    try {
        return request(GET, NodeInfo.class, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new NodeNotFoundException(nodeId);
            case 503:
                throw new NonSwarmNodeException("Node " + nodeId + " is not in a swarm", e);
            default:
                throw e;
        }
    }
}
Also used : NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 2 with NodeNotFoundException

use of com.spotify.docker.client.exceptions.NodeNotFoundException in project docker-client by spotify.

the class DefaultDockerClient method deleteNode.

@Override
public void deleteNode(final String nodeId, final boolean force) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    final WebTarget resource = resource().path("nodes").path(nodeId).queryParam("force", String.valueOf(force));
    try {
        request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new NodeNotFoundException(nodeId);
            case 503:
                throw new NonSwarmNodeException("Node " + nodeId + " is not a swarm node", e);
            default:
                throw e;
        }
    }
}
Also used : NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 3 with NodeNotFoundException

use of com.spotify.docker.client.exceptions.NodeNotFoundException in project docker-client by spotify.

the class DefaultDockerClient method updateNode.

@Override
public void updateNode(final String nodeId, final Long version, final NodeSpec nodeSpec) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.24");
    WebTarget resource = resource().path("nodes").path(nodeId).path("update").queryParam("version", version);
    try {
        request(POST, String.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(nodeSpec));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                throw new NodeNotFoundException(nodeId);
            case 503:
                throw new NonSwarmNodeException("Node " + nodeId + " is not a swarm node", e);
            default:
                throw e;
        }
    }
}
Also used : NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Aggregations

DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)3 NodeNotFoundException (com.spotify.docker.client.exceptions.NodeNotFoundException)3 NonSwarmNodeException (com.spotify.docker.client.exceptions.NonSwarmNodeException)3 WebTarget (javax.ws.rs.client.WebTarget)3