co.cask.common.http.HttpRequest.delete()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中co.cask.common.http.HttpRequest.delete()方法的一些代码示例,展示了HttpRequest.delete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.delete()方法的具体详情如下:
包路径:co.cask.common.http.HttpRequest
类名称:HttpRequest
方法名:delete

HttpRequest.delete介绍

暂无

代码示例

代码示例来源:origin: caskdata/cdap

@Override
public void dropRole(Role role) throws IOException, FeatureDisabledException, UnauthenticatedException,
 UnauthorizedException, NotFoundException, co.cask.cdap.security.spi.authorization.NotFoundException {
 URL url = config.resolveURLV3(String.format(AUTHORIZATION_BASE + "roles/%s", role.getName()));
 HttpRequest request = HttpRequest.delete(url).build();
 executeExistingRolesRequest(role, request);
}

代码示例来源:origin: caskdata/cdap

@Override
public void removeRoleFromPrincipal(Role role, Principal principal) throws IOException, FeatureDisabledException,
 UnauthenticatedException, UnauthorizedException, NotFoundException,
 co.cask.cdap.security.spi.authorization.NotFoundException {
 URL url = config.resolveURLV3(String.format(AUTHORIZATION_BASE + "%s/%s/roles/%s", principal.getType(),
                       principal.getName(), role.getName()));
 HttpRequest request = HttpRequest.delete(url).build();
 executeExistingRolesRequest(role, request);
}

代码示例来源:origin: caskdata/cdap

@Override
public void delete(NamespaceId namespaceId) throws Exception {
 URL url = resolve(String.format("unrecoverable/namespaces/%s", namespaceId.getNamespace()));
 HttpResponse response = execute(HttpRequest.delete(url).build());
 if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
  throw new NamespaceNotFoundException(namespaceId);
 } else if (HttpURLConnection.HTTP_FORBIDDEN == response.getResponseCode()) {
  throw new NamespaceCannotBeDeletedException(namespaceId, response.getResponseBodyAsString());
 } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
  return;
 }
 throw new IOException(String.format("Cannot delete namespace %s. Reason: %s",
                   namespaceId, response.getResponseBodyAsString()));
}

代码示例来源:origin: caskdata/cdap

@Override
public void deleteDatasets(NamespaceId namespaceId) throws Exception {
 URL url = resolve(String.format("unrecoverable/namespaces/%s/datasets", namespaceId.getNamespace()));
 HttpResponse response = execute(HttpRequest.delete(url).build());
 if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
  throw new NamespaceNotFoundException(namespaceId);
 } else if (HttpURLConnection.HTTP_FORBIDDEN == response.getResponseCode()) {
  String msg = String.format("Datasets in the namespace '%s' cannot be deleted. Reason: '%s'.", namespaceId,
                response.getResponseBodyAsString());
  throw new NamespaceCannotBeDeletedException(namespaceId, msg);
 } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
  return;
 }
 throw new IOException(String.format("Cannot delete datasets in namespace %s. Reason: %s",
                   namespaceId, response.getResponseBodyAsString()));
}

代码示例来源:origin: co.cask.cdap/cdap-common

@Override
public void deleteDatasets(NamespaceId namespaceId) throws Exception {
 URL url = resolve(String.format("unrecoverable/namespaces/%s/datasets", namespaceId.getNamespace()));
 HttpResponse response = execute(HttpRequest.delete(url).build());
 if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
  throw new NamespaceNotFoundException(namespaceId);
 } else if (HttpURLConnection.HTTP_FORBIDDEN == response.getResponseCode()) {
  String msg = String.format("Datasets in the namespace '%s' cannot be deleted. Reason: '%s'.", namespaceId,
                response.getResponseBodyAsString());
  throw new NamespaceCannotBeDeletedException(namespaceId, msg);
 } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
  return;
 }
 throw new IOException(String.format("Cannot delete datasets in namespace %s. Reason: %s",
                   namespaceId, response.getResponseBodyAsString()));
}

代码示例来源:origin: co.cask.cdap/cdap-common

@Override
public void delete(NamespaceId namespaceId) throws Exception {
 URL url = resolve(String.format("unrecoverable/namespaces/%s", namespaceId.getNamespace()));
 HttpResponse response = execute(HttpRequest.delete(url).build());
 if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
  throw new NamespaceNotFoundException(namespaceId);
 } else if (HttpURLConnection.HTTP_FORBIDDEN == response.getResponseCode()) {
  throw new NamespaceCannotBeDeletedException(namespaceId, response.getResponseBodyAsString());
 } else if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
  return;
 }
 throw new IOException(String.format("Cannot delete namespace %s. Reason: %s",
                   namespaceId, response.getResponseBodyAsString()));
}

代码示例来源:origin: cdapio/cdap

protected static HttpResponse doDelete(String resource) throws Exception {
 return HttpRequests.execute(HttpRequest.delete(getEndPoint(resource).toURL())
                .addHeader(Constants.Gateway.API_KEY, API_KEY).build(), httpRequestConfig);
}

代码示例来源:origin: cdapio/cdap

public HttpResponse delete(String key) throws Exception {
 return HttpRequests.execute(HttpRequest.delete(getURL("/v3/namespaces/default/securekeys/" + key)).build());
}

代码示例来源:origin: caskdata/cdap

private void validateDelete(URL url, Integer ... expected) throws IOException {
 HttpRequest request = HttpRequest.delete(url).build();
 assertStatus(HttpRequests.execute(request).getResponseCode(), url, expected);
}

代码示例来源:origin: caskdata/cdap

protected HttpResponse deleteModules(NamespaceId namespace) throws IOException {
 return HttpRequests.execute(HttpRequest.delete(getUrl(namespace.getEntityName(), "/data/modules/")).build());
}

代码示例来源:origin: caskdata/cdap

/**
 * Delete an artifact.
 *
 * @param artifactId the artifact to delete
 *
 * @throws BadRequestException if the request is invalid. For example, if the artifact name or version is invalid
 * @throws IOException if a network error occurred
 * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
 */
public void delete(ArtifactId artifactId)
 throws IOException, UnauthenticatedException, BadRequestException, UnauthorizedException {
 URL url = config.resolveNamespacedURLV3(artifactId.getParent(),
                     String.format("artifacts/%s/versions/%s",
                            artifactId.getArtifact(), artifactId.getVersion()));
 HttpRequest request = HttpRequest.delete(url).build();
 HttpResponse response = restClient.execute(request, config.getAccessToken(), HttpURLConnection.HTTP_BAD_REQUEST);
 int responseCode = response.getResponseCode();
 if (responseCode == HttpURLConnection.HTTP_BAD_REQUEST) {
  throw new BadRequestException(response.getResponseBodyAsString());
 }
}

代码示例来源:origin: caskdata/cdap

protected HttpResponse deleteModule(DatasetModuleId module) throws Exception {
 return HttpRequests.execute(
  HttpRequest.delete(getUrl(module.getNamespace(), "/data/modules/" + module.getEntityName())).build());
}

代码示例来源:origin: caskdata/cdap

/**
 * Delete all properties for an artifact. If no properties exist, this will be a no-op.
 *
 * @param artifactId the artifact to delete properties from
 * @throws BadRequestException if the request is invalid. For example, if the artifact name or version is invalid
 * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
 * @throws ArtifactNotFoundException if the artifact does not exist
 * @throws IOException if a network error occurred
 */
public void deleteProperties(ArtifactId artifactId)
 throws IOException, UnauthenticatedException, ArtifactNotFoundException,
 BadRequestException, UnauthorizedException {
 String path = String.format("artifacts/%s/versions/%s/properties",
               artifactId.getArtifact(),
               artifactId.getVersion());
 URL url = config.resolveNamespacedURLV3(artifactId.getParent(), path);
 HttpRequest.Builder requestBuilder = HttpRequest.delete(url);
 HttpRequest request = requestBuilder.build();
 HttpResponse response = restClient.execute(request, config.getAccessToken(),
                       HttpURLConnection.HTTP_BAD_REQUEST, HttpURLConnection.HTTP_NOT_FOUND);
 int responseCode = response.getResponseCode();
 if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
  throw new ArtifactNotFoundException(artifactId);
 } else if (responseCode == HttpURLConnection.HTTP_BAD_REQUEST) {
  throw new BadRequestException(response.getResponseBodyAsString());
 }
}

代码示例来源:origin: caskdata/cdap

private HttpResponse deleteInstance(DatasetId instance) throws IOException {
 HttpRequest request = HttpRequest.delete(getUrl(instance.getNamespace(),
                         "/data/datasets/" + instance.getEntityName())).build();
 return HttpRequests.execute(request);
}

代码示例来源:origin: caskdata/cdap

key);
URL url = config.resolveNamespacedURLV3(artifactId.getParent(), path);
HttpRequest.Builder requestBuilder = HttpRequest.delete(url);
HttpRequest request = requestBuilder.build();

代码示例来源:origin: cdapio/cdap

Assert.assertEquals(text, response.getResponseBodyAsString());
request = HttpRequest.delete(url).build();
response = HttpRequests.execute(request);
Assert.assertEquals(200, response.getResponseCode());

代码示例来源:origin: cdapio/cdap

response = HttpRequests.execute(HttpRequest.delete(serviceURI.resolve("delete/nn").toURL()).build());
Assert.assertEquals(200, response.getResponseCode());
response = HttpRequests.execute(HttpRequest.delete(serviceURI.resolve("delete/nn").toURL()).build());
Assert.assertEquals(404, response.getResponseCode());
response = HttpRequests.execute(HttpRequest.delete(serviceURI.resolve("delete/xx").toURL()).build());
Assert.assertEquals(404, response.getResponseCode());

相关文章