@Nonnull protected InvocationBuilder resourceWithAuthConfig(@Nonnull AuthConfig authConfig, @Nonnull InvocationBuilder request) { return request.header("X-Registry-Auth", registryAuth(authConfig)); }
@Override protected CreateNetworkResponse execute(CreateNetworkCmd command) { WebTarget webResource = getBaseResource().path("/networks/create"); LOGGER.trace("POST: {}", webResource); return webResource.request().accept(MediaType.APPLICATION_JSON) .post(command, new TypeReference<CreateNetworkResponse>() { }); } }
@Override public Info exec(InfoCmd command) { return webResource.path("info").request().get(new TypeReference<Info>() { }); }
@Override protected Void execute(ConnectToNetworkCmd command) { WebTarget webTarget = getBaseResource().path("/networks/" + command.getNetworkId() + "/connect"); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(command); return null; } }
@Override protected Void execute(LoadImageCmd command) { WebTarget webResource = getBaseResource().path("/images/load"); LOGGER.trace("POST: {}", webResource); webResource.request().postStream(command.getImageStream()); return null; } }
@Override protected Void execute(RemoveImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); webTarget = booleanQueryParam(webTarget, "noprune", command.hasNoPruneEnabled()); LOGGER.trace("DELETE: {}", webTarget); webTarget.request().delete(); return null; }
@Override protected Void execute(CopyArchiveToContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/archive").resolveTemplate("id", command.getContainerId()); LOGGER.trace("PUT: " + webResource.toString()); InputStream streamToUpload = command.getTarInputStream(); webResource.queryParam("path", command.getRemotePath()) .queryParam("noOverwriteDirNonDir", command.isNoOverwriteDirNonDir()).request() .put(streamToUpload, MediaType.APPLICATION_X_TAR); return null; } }
@Override protected Void execute(PingCmd command) { WebTarget webResource = getBaseResource().path("/_ping"); // TODO contribute to docker-java, make it close the stream IOUtils.closeQuietly(webResource.request().get()); return null; } };
@Override protected Void execute(DisconnectFromNetworkCmd command) { WebTarget webTarget = getBaseResource().path("/networks/" + command.getNetworkId() + "/disconnect"); LOGGER.trace("POST: {}", webTarget); webTarget.request().post(command); return null; } }
@Override protected Void execute(LoadImageCmd command) { WebTarget webResource = getBaseResource().path("/images/load"); LOGGER.trace("POST: {}", webResource); webResource.request().postStream(command.getImageStream()); return null; } }
@Override protected Void execute(RemoveImageCmd command) { WebTarget webTarget = getBaseResource().path("/images/" + command.getImageId()); webTarget = booleanQueryParam(webTarget, "force", command.hasForceEnabled()); webTarget = booleanQueryParam(webTarget, "noprune", command.hasNoPruneEnabled()); LOGGER.trace("DELETE: {}", webTarget); webTarget.request().delete(); return null; }
@Override protected Void execute(CopyArchiveToContainerCmd command) { WebTarget webResource = getBaseResource().path("/containers/{id}/archive").resolveTemplate("id", command.getContainerId()); LOGGER.trace("PUT: " + webResource.toString()); InputStream streamToUpload = command.getTarInputStream(); webResource.queryParam("path", command.getRemotePath()) .queryParam("noOverwriteDirNonDir", command.isNoOverwriteDirNonDir()).request() .put(streamToUpload, MediaType.APPLICATION_X_TAR); return null; } }
@Override protected CreateVolumeResponse execute(CreateVolumeCmd command) { WebTarget webResource = getBaseResource().path("/volumes/create"); LOGGER.trace("POST: {}", webResource); return webResource.request().accept(MediaType.APPLICATION_JSON) .post(command, new TypeReference<CreateVolumeResponse>() { }); } }
@Override protected Void execute(PingCmd command) { WebTarget webResource = getBaseResource().path("/_ping"); LOGGER.trace("GET: {}", webResource); webResource.request().get(); return null; }