Search in sources :

Example 6 with GsonEncoder

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);
}
Also used : GsonEncoder(feign.gson.GsonEncoder) Feign(feign.Feign) GsonDecoder(feign.gson.GsonDecoder)

Example 7 with GsonEncoder

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);
    }
}
Also used : Response(feign.Response) GsonEncoder(feign.gson.GsonEncoder)

Example 8 with GsonEncoder

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);
}
Also used : GsonEncoder(feign.gson.GsonEncoder) Retryer(feign.Retryer) Feign(feign.Feign) GsonDecoder(feign.gson.GsonDecoder)

Example 9 with GsonEncoder

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);
}
Also used : GsonEncoder(feign.gson.GsonEncoder) GsonDecoder(feign.gson.GsonDecoder)

Example 10 with GsonEncoder

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);
}
Also used : GsonEncoder(feign.gson.GsonEncoder) GsonDecoder(feign.gson.GsonDecoder)

Aggregations

GsonEncoder (feign.gson.GsonEncoder)10 GsonDecoder (feign.gson.GsonDecoder)8 ClientException (com.chinaunicom.etcd.v2.exception.ClientException)2 ServerException (com.chinaunicom.etcd.v2.exception.ServerException)2 Feign (feign.Feign)2 IOException (java.io.IOException)2 ApacheFeignHttpClient (org.wso2.carbon.apimgt.impl.kmclient.ApacheFeignHttpClient)2 KMClientErrorDecoder (org.wso2.carbon.apimgt.impl.kmclient.KMClientErrorDecoder)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Response (feign.Response)1 Retryer (feign.Retryer)1 BasicAuthRequestInterceptor (feign.auth.BasicAuthRequestInterceptor)1 Encoder (feign.codec.Encoder)1 JacksonEncoder (feign.jackson.JacksonEncoder)1 JAXBContextFactory (feign.jaxb.JAXBContextFactory)1 JAXBEncoder (feign.jaxb.JAXBEncoder)1 Slf4jLogger (feign.slf4j.Slf4jLogger)1 JsonFormat (org.nutz.json.JsonFormat)1 FormEncoder (org.wso2.carbon.apimgt.impl.kmclient.FormEncoder)1