use of com.spotify.docker.client.exceptions.NonSwarmNodeException in project docker-client by spotify.
the class DefaultDockerClient method inspectConfig.
@Override
public Config inspectConfig(final String configId) throws DockerException, InterruptedException {
assertApiVersionIsAbove("1.30");
final WebTarget resource = resource().path("configs").path(configId);
try {
return request(GET, Config.class, 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 swarm.", ex);
default:
throw ex;
}
}
}
use of com.spotify.docker.client.exceptions.NonSwarmNodeException in project docker-client by spotify.
the class DefaultDockerClient method createSecret.
@Override
public SecretCreateResponse createSecret(final SecretSpec secret) throws DockerException, InterruptedException {
assertApiVersionIsAbove("1.25");
final WebTarget resource = resource().path("secrets").path("create");
try {
return request(POST, SecretCreateResponse.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(secret));
} catch (final DockerRequestException ex) {
switch(ex.status()) {
case 406:
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 listConfigs.
@Override
public List<Config> listConfigs(final Config.Criteria criteria) throws DockerException, InterruptedException {
assertApiVersionIsAbove("1.30");
final Map<String, List<String>> filters = new HashMap<>();
if (criteria.configId() != null) {
filters.put("id", Collections.singletonList(criteria.configId()));
}
if (criteria.label() != null) {
filters.put("label", Collections.singletonList(criteria.label()));
}
if (criteria.name() != null) {
filters.put("name", Collections.singletonList(criteria.name()));
}
final WebTarget resource = resource().path("configs").queryParam("filters", urlEncodeFilters(filters));
try {
return request(GET, CONFIG_LIST, resource, resource.request(APPLICATION_JSON_TYPE));
} catch (DockerRequestException e) {
switch(e.status()) {
case 503:
throw new NonSwarmNodeException("node is 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 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;
}
}
}
use of com.spotify.docker.client.exceptions.NonSwarmNodeException in project docker-client by spotify.
the class DefaultDockerClient method listConfigs.
@Override
public List<Config> listConfigs() throws DockerException, InterruptedException {
assertApiVersionIsAbove("1.30");
final WebTarget resource = resource().path("configs");
try {
return request(GET, CONFIG_LIST, resource, resource.request(APPLICATION_JSON_TYPE));
} catch (DockerRequestException e) {
switch(e.status()) {
case 503:
throw new NonSwarmNodeException("node is not part of a swarm", e);
default:
throw e;
}
}
}
Aggregations