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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
Aggregations