@Override public Info info() throws DockerException, InterruptedException { final WebTarget resource = resource().path("info"); return request(GET, Info.class, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<ImageSearchResult> searchImages(final String term) throws DockerException, InterruptedException { final WebTarget resource = resource().path("images").path("search").queryParam("term", term); return request(GET, IMAGES_SEARCH_RESULT_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public Distribution getDistribution(String imageName) throws DockerException, InterruptedException { checkNotNull(imageName, "containerName"); final WebTarget resource = resource().path("distribution").path(imageName).path("json"); return request(GET, DISTRIBUTION, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public Version version() throws DockerException, InterruptedException { final WebTarget resource = resource().path("version"); return request(GET, Version.class, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public int auth(final RegistryAuth registryAuth) throws DockerException, InterruptedException { final WebTarget resource = resource().path("auth"); final Response response = request(POST, Response.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(registryAuth)); return response.getStatus(); }
@Override public List<Image> listImages(final ListImagesParam... params) throws DockerException, InterruptedException { WebTarget resource = resource() .path("images").path("json"); resource = addParameters(resource, params); return request(GET, IMAGE_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Task> listTasks() throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final WebTarget resource = resource().path("tasks"); return request(GET, TASK_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Network> listNetworks(final ListNetworksParam... params) throws DockerException, InterruptedException { WebTarget resource = resource().path("networks"); resource = addParameters(resource, params); return request(GET, NETWORK_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public Volume createVolume(final Volume volume) throws DockerException, InterruptedException { final WebTarget resource = resource().path("volumes").path("create"); return request(POST, Volume.class, resource, resource.request(APPLICATION_JSON_TYPE), Entity.json(volume)); }
@Override public VolumeList listVolumes(ListVolumesParam... params) throws DockerException, InterruptedException { WebTarget resource = resource().path("volumes"); resource = addParameters(resource, params); return request(GET, VolumeList.class, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Secret> listSecrets() throws DockerException, InterruptedException { assertApiVersionIsAbove("1.25"); final WebTarget resource = resource().path("secrets"); return request(GET, SECRET_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Node> listNodes() throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); WebTarget resource = resource().path("nodes"); return request(GET, NODE_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public List<Service> listServices() throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final WebTarget resource = resource().path("services"); return request(GET, SERVICE_LIST, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public Swarm inspectSwarm() throws DockerException, InterruptedException { assertApiVersionIsAbove("1.24"); final WebTarget resource = resource().path("swarm"); return request(GET, Swarm.class, resource, resource.request(APPLICATION_JSON_TYPE)); }
@Override public ImageInfo inspectImage(final String image) throws DockerException, InterruptedException { try { final WebTarget resource = resource().path("images").path(image).path("json"); return request(GET, ImageInfo.class, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ImageNotFoundException(image, e); default: throw e; } } }
@Override public ExecState execInspect(final String execId) throws DockerException, InterruptedException { final WebTarget resource = resource().path("exec").path(execId).path("json"); try { return request(GET, ExecState.class, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new ExecNotFoundException(execId, e); default: throw e; } } }
@Override public Network inspectNetwork(String networkId) throws DockerException, InterruptedException { final WebTarget resource = resource().path("networks").path(networkId); try { return request(GET, Network.class, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new NetworkNotFoundException(networkId, e); default: throw e; } } }
@Override public void removeNetwork(String networkId) throws DockerException, InterruptedException { try { final WebTarget resource = resource().path("networks").path(networkId); request(DELETE, resource, resource.request(APPLICATION_JSON_TYPE)); } catch (DockerRequestException e) { switch (e.status()) { case 404: throw new NetworkNotFoundException(networkId, e); default: throw e; } } }
@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; } } }
@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; } } }