use of com.microsoft.azure.hdinsight.spark.common.SparkBatchEspMfaSubmission in project azure-tools-for-java by Microsoft.
the class JobUtils method getEntity.
public static HttpEntity getEntity(@NotNull final IClusterDetail clusterDetail, @NotNull final String url) throws IOException, HDIException {
final HttpClient client;
if (clusterDetail instanceof MfaEspCluster) {
final String tenantId = ((MfaEspCluster) clusterDetail).getTenantId();
if (tenantId == null) {
throw new UnknownServiceException("Can't get HIB cluster Tenant ID");
}
client = new SparkBatchEspMfaSubmission(tenantId, clusterDetail.getName()).getHttpClient();
} else {
provider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(clusterDetail.getHttpUserName(), clusterDetail.getHttpPassword()));
client = HttpClients.custom().useSystemProperties().setDefaultCredentialsProvider(provider).build();
}
final HttpGet get = new HttpGet(url);
final HttpResponse response = client.execute(get);
final int code = response.getStatusLine().getStatusCode();
if (code == HttpStatus.SC_OK || code == HttpStatus.SC_CREATED) {
return response.getEntity();
} else {
throw new HDIException(response.getStatusLine().getReasonPhrase(), response.getStatusLine().getStatusCode());
}
}
Aggregations