Search in sources :

Example 6 with NotFoundException

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

the class DefaultDockerClient method disconnectFromNetwork.

@Override
public void disconnectFromNetwork(String containerId, String networkId, boolean force) throws DockerException, InterruptedException {
    final WebTarget resource = resource().path("networks").path(networkId).path("disconnect");
    final Map<String, Object> request = new HashMap<>();
    request.put("Container", containerId);
    request.put("Force", force);
    try {
        request(POST, String.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(request));
    } catch (DockerRequestException e) {
        switch(e.status()) {
            case 404:
                final String message = String.format("Container %s or network %s not found.", containerId, networkId);
                throw new NotFoundException(message, e);
            default:
                throw e;
        }
    }
}
Also used : Maps.newHashMap(com.google.common.collect.Maps.newHashMap) HashMap(java.util.HashMap) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) 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)

Example 7 with NotFoundException

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

the class DefaultDockerClient method deleteSecret.

@Override
public void deleteSecret(final String secretId) throws DockerException, InterruptedException {
    assertApiVersionIsAbove("1.25");
    final WebTarget resource = resource().path("secrets").path(secretId);
    try {
        request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE));
    } catch (final DockerRequestException ex) {
        switch(ex.status()) {
            case 404:
                throw new NotFoundException("Secret " + secretId + " not found.", 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)

Aggregations

ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)7 DockerRequestException (com.spotify.docker.client.exceptions.DockerRequestException)7 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)7 NetworkNotFoundException (com.spotify.docker.client.exceptions.NetworkNotFoundException)7 NotFoundException (com.spotify.docker.client.exceptions.NotFoundException)7 VolumeNotFoundException (com.spotify.docker.client.exceptions.VolumeNotFoundException)7 ExecNotFoundException (com.spotify.docker.client.exceptions.ExecNotFoundException)6 NodeNotFoundException (com.spotify.docker.client.exceptions.NodeNotFoundException)6 ServiceNotFoundException (com.spotify.docker.client.exceptions.ServiceNotFoundException)6 TaskNotFoundException (com.spotify.docker.client.exceptions.TaskNotFoundException)6 WebTarget (javax.ws.rs.client.WebTarget)6 NonSwarmNodeException (com.spotify.docker.client.exceptions.NonSwarmNodeException)4 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 ConflictException (com.spotify.docker.client.exceptions.ConflictException)1 ContainerRenameConflictException (com.spotify.docker.client.exceptions.ContainerRenameConflictException)1 DockerException (com.spotify.docker.client.exceptions.DockerException)1 Secret (com.spotify.docker.client.messages.swarm.Secret)1 SecretCreateResponse (com.spotify.docker.client.messages.swarm.SecretCreateResponse)1 SecretSpec (com.spotify.docker.client.messages.swarm.SecretSpec)1 Long.toHexString (java.lang.Long.toHexString)1