Skip to content

Commit 7d5c908

Browse files
committed
Register mysql resource provider when initialize intellij toolkit
1 parent 28292f7 commit 7d5c908

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

Utils/azuretools-core/src/com/microsoft/azuretools/utils/AzureRegisterProviderNamespaces.java

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,24 @@
66
package com.microsoft.azuretools.utils;
77

88
import com.microsoft.azure.management.Azure;
9-
import rx.Observable;
10-
import rx.schedulers.Schedulers;
9+
import org.apache.commons.lang3.StringUtils;
1110

12-
import java.util.concurrent.Callable;
11+
import java.util.Arrays;
1312

1413
public class AzureRegisterProviderNamespaces {
15-
public static void registerAzureNamespaces(Azure azureInstance) {
16-
String[] namespaces = new String[] {"Microsoft.Resources", "Microsoft.Network", "Microsoft.Compute",
17-
"Microsoft.KeyVault", "Microsoft.Storage", "Microsoft.Web", "Microsoft.Authorization", "Microsoft.HDInsight"};
18-
try {
19-
Observable.from(namespaces).flatMap(namespace -> {
20-
return Observable.fromCallable(new Callable<Object>() {
21-
@Override
22-
public Object call() throws Exception {
23-
azureInstance.providers().register(namespace);
24-
return null;
25-
}
26-
}).subscribeOn(Schedulers.io());
27-
}).toBlocking().subscribe();
28-
// azureInstance.providers().register("Microsoft.Resources");
29-
// azureInstance.providers().register("Microsoft.Network");
30-
// azureInstance.providers().register("Microsoft.Compute");
31-
// azureInstance.providers().register("Microsoft.KeyVault");
32-
// azureInstance.providers().register("Microsoft.Storage");
33-
// azureInstance.providers().register("Microsoft.Web");
34-
// azureInstance.providers().register("Microsoft.Authorization");
35-
// azureInstance.providers().register("Microsoft.HDInsight");
36-
} catch (Exception ignored) {
37-
// No need to handle this for now since this functionality will be eventually removed once the Azure SDK
38-
// something similar
14+
private static final String[] namespaces = new String[]{"Microsoft.Resources", "Microsoft.Network", "Microsoft.Compute", "Microsoft.KeyVault",
15+
"Microsoft.Storage", "Microsoft.Web", "Microsoft.Authorization", "Microsoft.HDInsight", "Microsoft.DBforMySQL"};
16+
17+
public static void registerAzureNamespaces(Azure azureInstance) {
18+
19+
try {
20+
Arrays.stream(namespaces).parallel()
21+
.map(azureInstance.providers()::getByName)
22+
.filter(provider -> !StringUtils.equalsIgnoreCase("Registered", provider.registrationState()))
23+
.forEach(provider -> azureInstance.providers().register(provider.namespace()));
24+
} catch (Exception ignored) {
25+
// No need to handle this for now since this functionality will be eventually removed once the Azure SDK
26+
// something similar
27+
}
3928
}
40-
}
4129
}

0 commit comments

Comments
 (0)