use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsNewDialog method populateResourceGroupValues.
private void populateResourceGroupValues(String subId, String valtoSet) {
try {
com.microsoft.azuretools.sdkmanage.AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
Azure azure = azureManager.getAzure(subId);
List<com.microsoft.azure.management.resources.ResourceGroup> groups = azure.resourceGroups().list();
List<String> groupStringList = groups.stream().map(com.microsoft.azure.management.resources.ResourceGroup::name).collect(Collectors.toList());
if (groupStringList.size() > 0) {
String[] groupArray = groupStringList.toArray(new String[groupStringList.size()]);
resourceGrpCombo.removeAll();
resourceGrpCombo.setItems(groupArray);
if (valtoSet.isEmpty() || !groupStringList.contains(valtoSet)) {
resourceGrpCombo.setText(groupArray[0]);
} else {
resourceGrpCombo.setText(valtoSet);
}
}
} catch (Exception ex) {
Activator.getDefault().log(Messages.getValuesErrMsg, ex);
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class AzureSDKManager method getApplicationInsightsResources.
public static List<Resource> getApplicationInsightsResources(@NotNull SubscriptionDetail subscription) throws Exception {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
if (azureManager == null) {
// not signed in
return null;
}
String tenantId = subscription.getTenantId();
return getApplicationManagementClient(tenantId, azureManager.getAccessToken(tenantId)).getResources(subscription.getSubscriptionId());
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class CreateNewDockerHostAction method actionPerformed.
@Override
public void actionPerformed(NodeActionEvent event) {
try {
if (!SignInCommandHandler.doSignIn(PluginUtil.getParentShell()))
return;
IProject project;
Shell shell = PluginUtil.getParentShell();
try {
project = AzureDockerUIResources.getCurrentSelectedProject();
} catch (Exception Ignored) {
project = null;
}
if (project == null) {
project = (IProject) dockerHostModule.getProject();
}
AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureAuthManager == null) {
return;
}
AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManager(azureAuthManager);
if (!dockerManager.isInitialized()) {
AzureDockerUIResources.updateAzureResourcesWithProgressDialog(shell, project);
if (AzureDockerUIResources.CANCELED) {
return;
}
dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(null);
}
if (dockerManager.getSubscriptionsMap().isEmpty()) {
PluginUtil.displayErrorDialog(shell, "Create Docker Host", "Must select an Azure subscription first");
return;
}
AzureNewDockerWizard newDockerWizard = new AzureNewDockerWizard(project, dockerManager);
WizardDialog createNewDockerHostDialog = new AzureWizardDialog(shell, newDockerWizard);
if (createNewDockerHostDialog.open() == Window.OK) {
newDockerWizard.createHost();
}
} catch (Exception ex1) {
log.log(Level.SEVERE, "actionPerformed", ex1);
ex1.printStackTrace();
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class SelectSubscriptionsAction method onShowSubscriptions.
public static void onShowSubscriptions(Project project) {
JFrame frame = WindowManager.getInstance().getFrame(project);
try {
//Project project = ProjectManager.getInstance().getDefaultProject();();
AzureManager manager = AuthMethodManager.getInstance().getAzureManager();
if (manager == null) {
return;
}
final SubscriptionManager subscriptionManager = manager.getSubscriptionManager();
updateSubscriptionWithProgressDialog(subscriptionManager, project);
List<SubscriptionDetail> sdl = subscriptionManager.getSubscriptionDetails();
for (SubscriptionDetail sd : sdl) {
System.out.println(sd.getSubscriptionName());
}
//System.out.println("onShowSubscriptions: calling getSubscriptionDetails()");
SubscriptionsDialog d = SubscriptionsDialog.go(subscriptionManager.getSubscriptionDetails(), project);
List<SubscriptionDetail> subscriptionDetailsUpdated;
if (d != null) {
subscriptionDetailsUpdated = d.getSubscriptionDetails();
subscriptionManager.setSubscriptionDetails(subscriptionDetailsUpdated);
}
} catch (Exception ex) {
ex.printStackTrace();
//LOGGER.error("onShowSubscriptions", ex);
ErrorWindow.show(project, ex.getMessage(), "Select Subscriptions Action Error");
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class Program method main.
@SuppressWarnings("unused")
public static void main(String[] args) {
LogManager.getLogManager().reset();
try {
try {
if (CommonSettings.getUiFactory() == null)
CommonSettings.setUiFactory(new UIFactory());
String wd = "AuthManageWorkingDir";
Path dirPath = Paths.get(System.getProperty("user.home"), wd);
if (!Files.exists(dirPath)) {
Files.createDirectory(dirPath);
}
CommonSettings.settingsBaseDir = dirPath.toString();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("--- Service Principals section ---");
// create with sp
//final File credFile = new File(System.getProperty("user.home") + "/ServicePrincipals/srv-pri.azureauth-778");
String path = "C:\\Users\\shch\\_ServicePrincipalsTest\\sp5\\sp-9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef_20161202161437.azureauth";
final File credFile = new File("C:\\Users\\shch\\_ServicePrincipalsTest\\sp5\\sp-9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef_20161202161437.azureauth");
AuthMethodDetails amd = new AuthMethodDetails();
amd.setAuthMethod(AuthMethod.SP);
amd.setCredFilePath(path);
AuthMethodManager amm = AuthMethodManager.getInstance();
amm.setAuthMethodDetails(amd);
AzureManager am = amm.getAzureManager();
SubscriptionManager subscriptionManager = am.getSubscriptionManager();
List<SubscriptionDetail> sdl = subscriptionManager.getSubscriptionDetails();
//AzureManager spManager = new ServicePrincipalAzureManager(credFile);
//printResourceGroups(spManager);
//printSubscriptions(spManager);
// create with token
//AzureManager atManager = new AccessTokenAzureManager(Constants.tenant);
//AzureManager atManager = new AccessTokenAzureManager();
//SubscriptionManager.getInstance().showSubscriptionDialog();
// AdAuthManager adAuthManager = AdAuthManager.getInstance();
System.out.println("=== Access token section ---");
// AuthenticationResult res = AdAuthManager.getInstance().signIn();
// UserInfo ui = res.getUserInfo();
// Setup working dir
String wd = "AuthManageWorkingDir";
Path dirPath = Paths.get(System.getProperty("user.home"), wd);
if (!Files.exists(dirPath)) {
Files.createDirectory(dirPath);
}
CommonSettings.settingsBaseDir = dirPath.toString();
// Setup uiFactory
if (CommonSettings.getUiFactory() == null)
CommonSettings.setUiFactory(new UIFactory());
//testReporter(dirPath.toString());
//graphApiAction();
//createSp();
// AzureManager am = AuthMethodManager.getInstance().getAzureManager(AuthMethod.AD);
// if (am == null) {
// return;
// }
//
// System.out.println("-- Subscription list ---");
// printSubscriptions(am);
// sidList = AdAuthManager.getInstance().getAccountSidList();
// for (String sid : AdAuthManager.getInstance().getAccountSidList()) {
// System.out.println(" - " + sid);
// }
//printResourceGroups(am);
//printTenants(atManager);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(1);
}
}
Aggregations