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