Search in sources :

Example 6 with NonSwarmNodeException

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

the class DefaultDockerClient method deleteConfig.

@Override
public void deleteConfig(final String configId) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.30");
    final WebTarget resource = resource().path("configs").path(configId);
    try {
        request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (final DockerRequestException ex) {
        switch(ex.status()) {
            case 404:
                throw new NotFoundException("Config " + configId + " not found.", ex);
            case 503:
                throw new NonSwarmNodeException("Config not part of a swarm.", ex);
            default:
                throw ex;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) TaskNotFoundException(com.spotify.docker.client.exceptions.TaskNotFoundException) ContainerNotFoundException(com.spotify.docker.client.exceptions.ContainerNotFoundException) NotFoundException(com.spotify.docker.client.exceptions.NotFoundException) NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) ImageNotFoundException(com.spotify.docker.client.exceptions.ImageNotFoundException) ServiceNotFoundException(com.spotify.docker.client.exceptions.ServiceNotFoundException) ExecNotFoundException(com.spotify.docker.client.exceptions.ExecNotFoundException) VolumeNotFoundException(com.spotify.docker.client.exceptions.VolumeNotFoundException) NetworkNotFoundException(com.spotify.docker.client.exceptions.NetworkNotFoundException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 7 with NonSwarmNodeException

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

the class DefaultDockerClient method updateConfig.

@Override
public void updateConfig(final String configId, final Long version, final ConfigSpec nodeSpec) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.30");
    final WebTarget resource = resource().path("configs").path(configId).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 NotFoundException("Config " + configId + " not found.");
            case 503:
                throw new NonSwarmNodeException("Config not part of a swarm.", e);
            default:
                throw e;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) TaskNotFoundException(com.spotify.docker.client.exceptions.TaskNotFoundException) ContainerNotFoundException(com.spotify.docker.client.exceptions.ContainerNotFoundException) NotFoundException(com.spotify.docker.client.exceptions.NotFoundException) NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) ImageNotFoundException(com.spotify.docker.client.exceptions.ImageNotFoundException) ServiceNotFoundException(com.spotify.docker.client.exceptions.ServiceNotFoundException) ExecNotFoundException(com.spotify.docker.client.exceptions.ExecNotFoundException) VolumeNotFoundException(com.spotify.docker.client.exceptions.VolumeNotFoundException) NetworkNotFoundException(com.spotify.docker.client.exceptions.NetworkNotFoundException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 8 with NonSwarmNodeException

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

the class DefaultDockerClient method inspectSecret.

@Override
public Secret inspectSecret(final String secretId) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.25");
    final WebTarget resource = resource().path("secrets").path(secretId);
    try {
        return request(GET, Secret.class, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (final DockerRequestException ex) {
        switch(ex.status()) {
            case 404:
                throw new NotFoundException("Secret " + secretId + " not found.", ex);
            case 406:
                throw new NonSwarmNodeException("Server not part of swarm.", ex);
            default:
                throw ex;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) TaskNotFoundException(com.spotify.docker.client.exceptions.TaskNotFoundException) ContainerNotFoundException(com.spotify.docker.client.exceptions.ContainerNotFoundException) NotFoundException(com.spotify.docker.client.exceptions.NotFoundException) NodeNotFoundException(com.spotify.docker.client.exceptions.NodeNotFoundException) ImageNotFoundException(com.spotify.docker.client.exceptions.ImageNotFoundException) ServiceNotFoundException(com.spotify.docker.client.exceptions.ServiceNotFoundException) ExecNotFoundException(com.spotify.docker.client.exceptions.ExecNotFoundException) VolumeNotFoundException(com.spotify.docker.client.exceptions.VolumeNotFoundException) NetworkNotFoundException(com.spotify.docker.client.exceptions.NetworkNotFoundException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 9 with NonSwarmNodeException

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

the class DefaultDockerClient method createConfig.

@Override
public ConfigCreateResponse createConfig(final ConfigSpec config) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.30");
    final WebTarget resource = resource().path("configs").path("create");
    try {
        return request(POST, ConfigCreateResponse.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(config));
    } catch (final DockerRequestException ex) {
        switch(ex.status()) {
            case 503:
                throw new NonSwarmNodeException("Server not part of swarm.", ex);
            case 409:
                throw new ConflictException("Name conflicts with an existing object.", ex);
            default:
                throw ex;
        }
    }
}
Also used : DockerRequestException(com.spotify.docker.client.exceptions.DockerRequestException) ContainerRenameConflictException(com.spotify.docker.client.exceptions.ContainerRenameConflictException) ConflictException(com.spotify.docker.client.exceptions.ConflictException) ExecStartConflictException(com.spotify.docker.client.exceptions.ExecStartConflictException) ExecCreateConflictException(com.spotify.docker.client.exceptions.ExecCreateConflictException) WebTarget(javax.ws.rs.client.WebTarget) NonSwarmNodeException(com.spotify.docker.client.exceptions.NonSwarmNodeException)

Example 10 with NonSwarmNodeException

use of com.spotify.docker.client.exceptions.NonSwarmNodeException 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)

Aggregations

DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)11 NonSwarmNodeException (com.spotify.docker.client.exceptions.NonSwarmNodeException)11 WebTarget (javax.ws.rs.client.WebTarget)11 NodeNotFoundException (com.spotify.docker.client.exceptions.NodeNotFoundException)7 ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)4 ExecNotFoundException (com.spotify.docker.client.exceptions.ExecNotFoundException)4 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)4 NetworkNotFoundException (com.spotify.docker.client.exceptions.NetworkNotFoundException)4 NotFoundException (com.spotify.docker.client.exceptions.NotFoundException)4 ServiceNotFoundException (com.spotify.docker.client.exceptions.ServiceNotFoundException)4 TaskNotFoundException (com.spotify.docker.client.exceptions.TaskNotFoundException)4 VolumeNotFoundException (com.spotify.docker.client.exceptions.VolumeNotFoundException)4 ConflictException (com.spotify.docker.client.exceptions.ConflictException)2 ContainerRenameConflictException (com.spotify.docker.client.exceptions.ContainerRenameConflictException)2 ExecCreateConflictException (com.spotify.docker.client.exceptions.ExecCreateConflictException)2 ExecStartConflictException (com.spotify.docker.client.exceptions.ExecStartConflictException)2 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 VolumeList (com.spotify.docker.client.messages.VolumeList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1