@Override public String ping() throws DockerException, InterruptedException { final WebTarget resource = client.target(uri).path("_ping"); return request(GET, String.class, resource, resource.request()); }
@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 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)); }
private void requestAndTail(final String method, final ProgressHandler handler, final WebTarget resource, final Invocation.Builder request, final Entity<?> entity) throws DockerException, InterruptedException { Response response = request(method, Response.class, resource, request, entity); tailResponse(method, response, handler, resource); }
@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 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 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<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 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 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 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; } } }
private void requestAndTail(final String method, final ProgressHandler handler, final WebTarget resource, final Invocation.Builder request) throws DockerException, InterruptedException { Response response = request(method, Response.class, resource, request); if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { throw new DockerRequestException(method, resource.getUri(), response.getStatus(), message(response), null); } tailResponse(method, response, handler, resource); }