Search in sources :

Example 16 with HttpRequest

use of io.cdap.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method getInstance.

private HttpResponse getInstance(DatasetId instance) throws IOException {
    URL instanceUrl = getUrl(instance.getNamespace(), "/data/datasets/" + instance.getEntityName());
    HttpRequest request = HttpRequest.get(instanceUrl).build();
    return HttpRequests.execute(request, REQUEST_CONFIG);
}
Also used : HttpRequest(io.cdap.common.http.HttpRequest) URL(java.net.URL)

Example 17 with HttpRequest

use of io.cdap.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method createInstance.

private HttpResponse createInstance(DatasetId instance, String typeName, @Nullable String description, @Nullable DatasetProperties props, @Nullable String ownerPrincipal) throws IOException {
    DatasetInstanceConfiguration creationProperties;
    if (props != null) {
        creationProperties = new DatasetInstanceConfiguration(typeName, props.getProperties(), description, ownerPrincipal);
    } else {
        creationProperties = new DatasetInstanceConfiguration(typeName, null, description, ownerPrincipal);
    }
    HttpRequest request = HttpRequest.put(getUrl(instance.getNamespace(), "/data/datasets/" + instance.getEntityName())).withBody(GSON.toJson(creationProperties)).build();
    return HttpRequests.execute(request, REQUEST_CONFIG);
}
Also used : HttpRequest(io.cdap.common.http.HttpRequest) DatasetInstanceConfiguration(io.cdap.cdap.proto.DatasetInstanceConfiguration)

Example 18 with HttpRequest

use of io.cdap.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method validateGet.

private void validateGet(URL url, Integer... expected) throws IOException {
    HttpRequest request = HttpRequest.get(url).build();
    assertStatus(HttpRequests.execute(request, REQUEST_CONFIG).getResponseCode(), url, expected);
}
Also used : HttpRequest(io.cdap.common.http.HttpRequest)

Example 19 with HttpRequest

use of io.cdap.common.http.HttpRequest in project cdap by caskdata.

the class DatasetInstanceHandlerTest method validatePost.

private void validatePost(URL url, String body, Integer... expected) throws IOException {
    HttpRequest request = HttpRequest.post(url).withBody(body).build();
    assertStatus(HttpRequests.execute(request, REQUEST_CONFIG).getResponseCode(), url, expected);
}
Also used : HttpRequest(io.cdap.common.http.HttpRequest)

Example 20 with HttpRequest

use of io.cdap.common.http.HttpRequest in project cdap by caskdata.

the class SparkProgramStatusMetricsProvider method doGet.

private HttpResponse doGet(String url) throws IOException {
    URL requestURL = new URL(url);
    HttpRequest httpRequest = HttpRequest.get(requestURL).build();
    return HttpRequests.execute(httpRequest, httpRequestConfig);
}
Also used : HttpRequest(io.cdap.common.http.HttpRequest) URL(java.net.URL)

Aggregations

HttpRequest (io.cdap.common.http.HttpRequest)124 HttpResponse (io.cdap.common.http.HttpResponse)92 URL (java.net.URL)81 Test (org.junit.Test)33 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)14 IOException (java.io.IOException)14 AccessToken (io.cdap.cdap.security.authentication.client.AccessToken)13 DefaultHttpRequestConfig (io.cdap.cdap.common.http.DefaultHttpRequestConfig)10 BadRequestException (io.cdap.cdap.common.BadRequestException)9 NotFoundException (io.cdap.cdap.common.NotFoundException)8 TopicNotFoundException (io.cdap.cdap.api.messaging.TopicNotFoundException)5 ServiceManager (io.cdap.cdap.test.ServiceManager)5 TypeToken (com.google.gson.reflect.TypeToken)4 KeyValueTable (io.cdap.cdap.api.dataset.lib.KeyValueTable)4 ApplicationNotFoundException (io.cdap.cdap.common.ApplicationNotFoundException)4 ArtifactNotFoundException (io.cdap.cdap.common.ArtifactNotFoundException)4 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)4 TopicId (io.cdap.cdap.proto.id.TopicId)4 ApplicationManager (io.cdap.cdap.test.ApplicationManager)4 ByteBuffer (java.nio.ByteBuffer)4