use of feign.gson.GsonEncoder in project pravega by pravega.
the class MetronomeClient method getInstance.
/*
* The generalized version of the method that allows more in-depth customizations via
* {@link RequestInterceptor}s.
*
* @param endpoint URL of Metronome
*/
public static Metronome getInstance(String endpoint, RequestInterceptor... interceptors) {
Feign.Builder b = Feign.builder().client(LoginClient.getClientHostVerificationDisabled()).logger(new Logger.ErrorLogger()).logLevel(Logger.Level.BASIC).encoder(new GsonEncoder(ModelUtils.GSON)).decoder(new GsonDecoder(ModelUtils.GSON)).retryer(new Retryer.Default(SECONDS.toMillis(1), SECONDS.toMillis(5), 5)).errorDecoder(new MetronomeErrorDecoder());
if (interceptors != null) {
b.requestInterceptors(asList(interceptors));
}
b.requestInterceptor(new MetronomeHeadersInterceptor());
return b.target(Metronome.class, endpoint);
}
use of feign.gson.GsonEncoder in project pravega by pravega.
the class LoginClient method getAuthToken.
/**
* Fetch the token from the authentication service.
*
* @param loginURL Login Url.
* @return Auth token.
*/
public static String getAuthToken(final String loginURL) {
Login client = Feign.builder().client(getClientHostVerificationDisabled()).encoder(new GsonEncoder(ModelUtils.GSON)).target(Login.class, loginURL);
Response response = client.login(new AuthRequest(getUsername(), getPassword(), "LOCAL"));
if (response.status() == OK.getStatusCode()) {
Collection<String> headers = response.headers().get(TOKEN_HEADER_NAME);
return headers.toArray(new String[headers.size()])[0];
} else {
throw new TestFrameworkException(TestFrameworkException.Type.LoginFailed, "Exception while " + "logging into the cluster. Authentication service returned the following error: " + response);
}
}
use of feign.gson.GsonEncoder in project pravega by pravega.
the class AuthEnabledMarathonClient method getInstance.
private static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
Feign.Builder b = Feign.builder().client(LoginClient.getClientHostVerificationDisabled()).logger(new Logger.ErrorLogger()).logLevel(Logger.Level.BASIC).encoder(new GsonEncoder(ModelUtils.GSON)).decoder(new GsonDecoder(ModelUtils.GSON)).errorDecoder(new MarathonErrorDecoder()).retryer(new Retryer.Default(SECONDS.toMillis(1), SECONDS.toMillis(5), 5));
if (interceptors != null) {
b.requestInterceptors(asList(interceptors));
}
b.requestInterceptor(new MarathonHeadersInterceptor());
return b.target(Marathon.class, endpoint);
}
use of feign.gson.GsonEncoder in project mesosFramework by zhizuqiu.
the class MesosClient method getInstance.
public static MesosIf getInstance(String url) {
GsonDecoder decoder = new GsonDecoder(GSON);
GsonEncoder encoder = new GsonEncoder(GSON);
return Feign.builder().encoder(encoder).decoder(decoder).errorDecoder(new MesosErrorDecoder()).requestInterceptor(new MesosHeadersInterceptor()).target(MesosIf.class, url);
}
use of feign.gson.GsonEncoder in project mesosFramework by zhizuqiu.
the class EtcdClient method getInstance.
public static Etcd getInstance(String url) {
GsonDecoder decoder = new GsonDecoder(GSON);
GsonEncoder encoder = new GsonEncoder(GSON);
return Feign.builder().encoder(encoder).decoder(decoder).errorDecoder(new EtcdErrorDecoder()).requestInterceptor(new EtcdHeadersInterceptor()).target(Etcd.class, url);
}
Aggregations