gooddata-http-client

HTTP client with ability to handle GoodData authentication

License

License

Categories

Categories

Data CLI User Interface
GroupId

GroupId

com.gooddata
ArtifactId

ArtifactId

gooddata-http-client
Last Version

Last Version

1.0.0+java7.fix1
Release Date

Release Date

Type

Type

jar
Description

Description

gooddata-http-client
HTTP client with ability to handle GoodData authentication
Project URL

Project URL

https://github.com/gooddata/gooddata-http-client
Source Code Management

Source Code Management

https://github.com/gooddata/gooddata-http-client

Download gooddata-http-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.gooddata/gooddata-http-client/ -->
<dependency>
    <groupId>com.gooddata</groupId>
    <artifactId>gooddata-http-client</artifactId>
    <version>1.0.0+java7.fix1</version>
</dependency>
// https://jarcasting.com/artifacts/com.gooddata/gooddata-http-client/
implementation 'com.gooddata:gooddata-http-client:1.0.0+java7.fix1'
// https://jarcasting.com/artifacts/com.gooddata/gooddata-http-client/
implementation ("com.gooddata:gooddata-http-client:1.0.0+java7.fix1")
'com.gooddata:gooddata-http-client:jar:1.0.0+java7.fix1'
<dependency org="com.gooddata" name="gooddata-http-client" rev="1.0.0+java7.fix1">
  <artifact name="gooddata-http-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gooddata', module='gooddata-http-client', version='1.0.0+java7.fix1')
)
libraryDependencies += "com.gooddata" % "gooddata-http-client" % "1.0.0+java7.fix1"
[com.gooddata/gooddata-http-client "1.0.0+java7.fix1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.httpcomponents : httpclient jar 4.5.10
org.apache.httpcomponents : httpcore jar 4.4.12
org.apache.commons : commons-lang3 jar 3.8.1
org.slf4j : slf4j-api jar 1.7.28

test (8)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.28
junit : junit jar 4.12
org.mockito : mockito-core jar 2.28.2
commons-io : commons-io jar 2.6
org.hamcrest : hamcrest jar 2.1
net.jadler : jadler-all jar 1.3.0
net.jadler : jadler-core jar 1.3.0
com.fasterxml.jackson.core : jackson-databind jar 2.10.0

Project Modules

There are no modules declared in this project.

GoodData HTTP Client Build Status Javadocs Maven Central

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.

Design

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.

Usage

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>

Authentication using credentials

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()));

Authentication using super-secure token (SST)

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()));

Build

mvn package

Unit tests

mvn test

Acceptance tests (with real backend)

mvn -P at clean verify [email protected] -DGDC_PASSWORD=password [-DGDC_BACKEND=<backend host>]

Test coverage

One can check test coverage report in coveralls.io.

Notice

GoodData Corporation provides this software "as-is" under conditions specified in the license.

com.gooddata

GoodData

Versions

Version
1.0.0+java7.fix1
1.0.0+java7
1.0.0
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0