use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class RESTClientTest method testDeleteSuccessWithAccessToken.
@Test
public void testDeleteSuccessWithAccessToken() throws Exception {
URL url = getBaseURI().resolve("/api/testDeleteAuth").toURL();
HttpRequest request = HttpRequest.delete(url).build();
HttpResponse response = restClient.execute(request, new AccessToken(ACCESS_TOKEN, 82000L, "Bearer"));
verifyResponse(response, only(200), any(), only("Access token received: " + ACCESS_TOKEN));
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class RESTClientTest method testDeleteUnauthorizedWithAccessToken.
@Test(expected = UnauthenticatedException.class)
public void testDeleteUnauthorizedWithAccessToken() throws Exception {
URL url = getBaseURI().resolve("/api/testDeleteAuth").toURL();
HttpRequest request = HttpRequest.delete(url).build();
restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DefaultMetadataServiceClient method batch.
@Override
public void batch(List<MetadataMutation> mutations) {
HttpRequest request = remoteClient.requestBuilder(HttpMethod.POST, "metadata-internals/batch").withBody(GSON.toJson(mutations)).build();
HttpResponse response = execute(request);
if (HttpResponseStatus.OK.code() != response.getResponseCode()) {
LOG.trace("Failed to apply metadata mutations for mutations %s: %s", mutations, response);
}
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class DefaultMetadataServiceClient method create.
@Override
public void create(MetadataMutation.Create createMutation) {
HttpRequest request = remoteClient.requestBuilder(HttpMethod.POST, "metadata-internals/create").withBody(GSON.toJson(createMutation)).build();
HttpResponse response = execute(request);
if (HttpResponseStatus.OK.code() != response.getResponseCode()) {
LOG.trace("Failed to create metadata for entity %s: %s", createMutation.getEntity(), response);
}
}
use of io.cdap.common.http.HttpRequest in project cdap by caskdata.
the class RemoteAccessEnforcer method visibilityCheckCall.
private Set<? extends EntityId> visibilityCheckCall(VisibilityRequest visibilityRequest) throws IOException, UnauthorizedException {
HttpRequest request = remoteClient.requestBuilder(HttpMethod.POST, "isVisible").withBody(GSON.toJson(visibilityRequest)).build();
LOG.trace("Remotely checking visibility on authorization privilege {}", visibilityRequest);
return GSON.fromJson(remoteClient.execute(request).getResponseBodyAsString(), SET_ENTITY_TYPE);
}
Aggregations