use of com.microsoft.azure.management.datalake.analytics.implementation.DataLakeAnalyticsAccountManagementClientImpl in project azure-sdk-for-java by Azure.
the class DataLakeAnalyticsManagementTestBase method initializeClients.
@Override
protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) {
rgName = generateRandomResourceName("adlarg", 15);
adlsName = generateRandomResourceName("adls", 15);
jobAndCatalogAdlaName = generateRandomResourceName("secondadla", 15);
environmentLocation = Region.US_EAST2;
dataLakeAnalyticsAccountManagementClient = new DataLakeAnalyticsAccountManagementClientImpl(restClient).withSubscriptionId(defaultSubscription);
// TODO: in the future this needs to be dynamic depending on the Azure environment
// the tests are running in.
String adlaSuffix = "azuredatalakeanalytics.net";
addTextReplacementRule("https://(.*)." + adlaSuffix, this.mockUri());
// Generate creds and a set of rest clients for catalog and job
ApplicationTokenCredentials credentials = new AzureTestCredentials();
if (IS_RECORD) {
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
try {
credentials = ApplicationTokenCredentials.fromFile(credFile);
} catch (IOException e) {
Assert.fail("Failed to read credentials from file: " + credFile + " with error: " + e.getMessage());
}
}
if (IS_RECORD) {
RestClient restClientWithTimeout = buildRestClient(new RestClient.Builder().withConnectionTimeout(5, TimeUnit.MINUTES).withBaseUrl("https://{accountName}.{adlaJobDnsSuffix}").withCredentials(credentials).withLogLevel(LogLevel.BODY_AND_HEADERS).withNetworkInterceptor(this.interceptor()), IS_MOCKED);
dataLakeAnalyticsJobManagementClient = new DataLakeAnalyticsJobManagementClientImpl(restClientWithTimeout).withAdlaJobDnsSuffix(adlaSuffix);
RestClient catalogRestClient = buildRestClient(new RestClient.Builder().withBaseUrl("https://{accountName}.{adlaCatalogDnsSuffix}").withCredentials(credentials).withLogLevel(LogLevel.BODY_AND_HEADERS).withNetworkInterceptor(this.interceptor()), IS_MOCKED);
dataLakeAnalyticsCatalogManagementClient = new DataLakeAnalyticsCatalogManagementClientImpl(catalogRestClient).withAdlaCatalogDnsSuffix(adlaSuffix);
} else {
// for mocked clients, we can just use the basic rest client, since the DNS is replaced.
dataLakeAnalyticsCatalogManagementClient = new DataLakeAnalyticsCatalogManagementClientImpl(restClient);
dataLakeAnalyticsJobManagementClient = new DataLakeAnalyticsJobManagementClientImpl(restClient);
}
resourceManagementClient = ResourceManager.authenticate(restClient).withSubscription(defaultSubscription);
dataLakeStoreAccountManagementClient = new DataLakeStoreAccountManagementClientImpl(restClient).withSubscriptionId(defaultSubscription);
storageManagementClient = StorageManager.authenticate(restClient, defaultSubscription);
// create the resource group, ADLS account and ADLA account for job and catalog use.
resourceManagementClient.resourceGroups().define(rgName).withRegion(environmentLocation).create();
DataLakeStoreAccount createParams = new DataLakeStoreAccount();
createParams.withLocation(environmentLocation.name());
dataLakeStoreAccountManagementClient.accounts().create(rgName, adlsName, createParams);
List<DataLakeStoreAccountInfo> adlsAccts = new ArrayList<DataLakeStoreAccountInfo>();
DataLakeStoreAccountInfo adlsInfo = new DataLakeStoreAccountInfo();
adlsInfo.withName(adlsName);
adlsAccts.add(adlsInfo);
DataLakeAnalyticsAccount adlaCreateParams = new DataLakeAnalyticsAccount();
adlaCreateParams.withLocation(environmentLocation.name());
adlaCreateParams.withDataLakeStoreAccounts(adlsAccts);
adlaCreateParams.withDefaultDataLakeStoreAccount(adlsName);
dataLakeAnalyticsAccountManagementClient.accounts().create(rgName, jobAndCatalogAdlaName, adlaCreateParams);
}
Aggregations