GoodData HTTP Client is an extension of Apache HTTP Client (former Jakarta Commons). This specialized Java client transparently handles GoodData authentication so you can focus on writing logic on top of GoodData API.
com.gooddata.http.client.GoodDataHttpClient
central class implements org.apache.http.client.HttpClient interface
It allows seamless switch for existing code base currently using org.apache.http.client.HttpClient
. Business logic encapsulating
access to GoodData API should use org.apache.http.client.HttpClient
interface
and keep com.gooddata.http.client.GoodDataHttpClient
inside a factory class. com.gooddata.http.client.GoodDataHttpClient
uses underlying org.apache.http.client.HttpClient
. A HTTP client
instance can be passed via the constructor.
Authentication to GoodData is supported by credentials or Super Secure Token.
If your project is managed by Maven you can add GoodData HTTP client as a new dependency otherwise you have to download binary and add manually.
Maven
<dependency>
<groupId>com.gooddata</groupId>
<artifactId>gooddata-http-client</artifactId>
<version>${gdc.http.client.version}</version>
</dependency>
import com.gooddata.http.client.*
import java.io.IOException;
import org.apache.http.*;
HttpHost hostGoodData = new HttpHost("secure.gooddata.com", 443, "https");
// create login strategy, which will obtain SST via credentials
SSTRetrievalStrategy sstStrategy = new LoginSSTRetrievalStrategy(login, password);
HttpClient client = new GoodDataHttpClient(HttpClientBuilder.create().build(), hostGoodData, sstStrategy);
// use HTTP client with transparent GoodData authentication
HttpGet getProject = new HttpGet("/gdc/projects");
getProject.addHeader("Accept", ContentType.APPLICATION_JSON.getMimeType());
HttpResponse getProjectResponse = client.execute(hostGoodData, getProject);
System.out.println(EntityUtils.toString(getProjectResponse.getEntity()));
import com.gooddata.http.client.*
import java.io.IOException;
import org.apache.http.*;
// create HTTP client
HttpClient httpClient = HttpClientBuilder.create().build();
HttpHost hostGoodData = new HttpHost("secure.gooddata.com", 443, "https");
// create login strategy (you must somehow obtain SST)
SSTRetrievalStrategy sstStrategy = new SimpleSSTRetrievalStrategy("my super-secure token");
// wrap your HTTP client into GoodData HTTP client
HttpClient client = new GoodDataHttpClient(httpClient, hostGoodData, sstStrategy);
// use GoodData HTTP client
HttpGet getProject = new HttpGet("/gdc/projects");
getProject.addHeader("Accept", ContentType.APPLICATION_JSON.getMimeType());
HttpResponse getProjectResponse = client.execute(hostGoodData, getProject);
System.out.println(EntityUtils.toString(getProjectResponse.getEntity()));
mvn package
mvn test
mvn -P at clean verify [email protected] -DGDC_PASSWORD=password [-DGDC_BACKEND=<backend host>]
GoodData Corporation provides this software "as-is" under conditions specified in the license.