use of com.microsoft.azure.management.resources.fluentcore.utils.ResourceManagerThrottlingInterceptor in project photon-model by vmware.
the class AzureSdkClients method buildRestClient.
/**
* Build Azure RestClient with specified executor service and credentials using
* {@link RestClient.Builder}.
*/
private static RestClient buildRestClient(ApplicationTokenCredentials credentials, ExecutorService executorService) {
final Retrofit.Builder retrofitBuilder;
{
retrofitBuilder = new Retrofit.Builder();
if (executorService != null) {
RxJavaCallAdapterFactory rxWithExecutorCallFactory = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.from(executorService));
retrofitBuilder.addCallAdapterFactory(rxWithExecutorCallFactory);
}
}
final RestClient.Builder restClientBuilder = new RestClient.Builder(new OkHttpClient.Builder(), retrofitBuilder);
restClientBuilder.withBaseUrl(AzureUtils.getAzureBaseUri());
restClientBuilder.withCredentials(credentials);
restClientBuilder.withSerializerAdapter(new AzureJacksonAdapter());
restClientBuilder.withLogLevel(getRestClientLogLevel());
restClientBuilder.withInterceptor(new ResourceManagerThrottlingInterceptor());
if (executorService != null) {
restClientBuilder.withCallbackExecutor(executorService);
}
restClientBuilder.withResponseBuilderFactory(new Factory());
return restClientBuilder.build();
}
Aggregations