Search in sources :

Example 1 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ExternalStorageAccountForm method populateFullStorageAccount.

public void populateFullStorageAccount() {
    ClientStorageAccount clientStorageAccount = new ClientStorageAccount(accountNameTextField.getText());
    clientStorageAccount.setPrimaryKey(accountKeyTextField.getText());
    clientStorageAccount.setUseCustomEndpoints(specifyCustomEndpointsRadioButton.getSelection());
    if (specifyCustomEndpointsRadioButton.getSelection()) {
        clientStorageAccount.setBlobsUri(blobURLTextField.getText());
        clientStorageAccount.setQueuesUri(queueURLTextField.getText());
        clientStorageAccount.setTablesUri(tableURLTextField.getText());
    } else {
        clientStorageAccount.setProtocol(useHTTPRadioButton.getSelection() ? HTTP : HTTPS);
    }
    fullStorageAccount = clientStorageAccount;
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Example 2 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ExternalStorageAccountForm method getStorageAccount.

public ClientStorageAccount getStorageAccount() {
    ClientStorageAccount clientStorageAccount = new ClientStorageAccount(accountNameTextField.getText());
    clientStorageAccount.setUseCustomEndpoints(specifyCustomEndpointsRadioButton.isSelected());
    if (rememberAccountKeyCheckBox.isSelected()) {
        clientStorageAccount.setPrimaryKey(accountKeyTextField.getText());
    }
    if (specifyCustomEndpointsRadioButton.isSelected()) {
        clientStorageAccount.setBlobsUri(blobURLTextField.getText());
        clientStorageAccount.setQueuesUri(queueURLTextField.getText());
        clientStorageAccount.setTablesUri(tableURLTextField.getText());
    } else {
        clientStorageAccount.setProtocol(useHTTPRadioButton.isSelected() ? HTTP : HTTPS);
    }
    return clientStorageAccount;
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Example 3 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ModifyExternalStorageAccountAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) storageNode.getProject());
    form.setTitle("Modify External Storage Account");
    for (ClientStorageAccount account : ExternalStorageHelper.getList(storageNode.getProject())) {
        if (account.getName().equals(storageNode.getClientStorageAccount().getName())) {
            form.setStorageAccount(account);
        }
    }
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            ClientStorageAccount oldStorageAccount = storageNode.getClientStorageAccount();
            ClientStorageAccount storageAccount = StorageClientSDKManager.getManager().getStorageAccount(form.getStorageAccount().getConnectionString());
            ClientStorageAccount fullStorageAccount = form.getFullStorageAccount();
            StorageModule parent = (StorageModule) storageNode.getParent();
            parent.removeDirectChildNode(storageNode);
            parent.addChildNode(new ExternalStorageNode(parent, fullStorageAccount));
            ExternalStorageHelper.detach(oldStorageAccount);
            ExternalStorageHelper.add(form.getStorageAccount());
        }
    });
    form.show();
}
Also used : StorageModule(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)

Example 4 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class ConfirmDialogAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    final ExternalStorageNode node = (ExternalStorageNode) e.getAction().getNode();
    final ExternalStorageAccountForm form = new ExternalStorageAccountForm((Project) node.getProject());
    form.setTitle("Storage Account Key Required");
    form.setStorageAccount(node.getClientStorageAccount());
    form.setOnFinish(new Runnable() {

        @Override
        public void run() {
            node.getClientStorageAccount().setPrimaryKey(form.getPrimaryKey());
            ClientStorageAccount clientStorageAccount = StorageClientSDKManager.getManager().getStorageAccount(node.getClientStorageAccount().getConnectionString());
            node.getClientStorageAccount().setPrimaryKey(clientStorageAccount.getPrimaryKey());
            node.getClientStorageAccount().setBlobsUri(clientStorageAccount.getBlobsUri());
            node.getClientStorageAccount().setQueuesUri(clientStorageAccount.getQueuesUri());
            node.getClientStorageAccount().setTablesUri(clientStorageAccount.getTablesUri());
            node.load(false);
        }
    });
    form.show();
}
Also used : ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ExternalStorageNode(com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode) ExternalStorageAccountForm(com.microsoft.intellij.forms.ExternalStorageAccountForm)

Example 5 with ClientStorageAccount

use of com.microsoft.tooling.msservices.model.storage.ClientStorageAccount in project azure-tools-for-java by Microsoft.

the class StorageModule method refreshItems.

@Override
protected void refreshItems() throws AzureCmdException {
    List<Pair<String, String>> failedSubscriptions = new ArrayList<>();
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureManager == null) {
            return;
        }
        SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
        Set<String> sidList = subscriptionManager.getAccountSidList();
        for (String sid : sidList) {
            try {
                Azure azure = azureManager.getAzure(sid);
                List<com.microsoft.azure.management.storage.StorageAccount> storageAccounts = azure.storageAccounts().list();
                for (StorageAccount sm : storageAccounts) {
                    addChildNode(new StorageNode(this, sid, sm));
                }
            } catch (Exception ex) {
                failedSubscriptions.add(new ImmutablePair<>(sid, ex.getMessage()));
                continue;
            }
        }
    } catch (Exception ex) {
        DefaultLoader.getUIHelper().logError("An error occurred when trying to load Storage Accounts\n\n" + ex.getMessage(), ex);
    }
    // load External Accounts
    for (ClientStorageAccount clientStorageAccount : ExternalStorageHelper.getList(getProject())) {
        ClientStorageAccount storageAccount = StorageClientSDKManager.getManager().getStorageAccount(clientStorageAccount.getConnectionString());
    //            addChildNode(new ExternalStorageNode(this, storageAccount));
    }
    if (!failedSubscriptions.isEmpty()) {
        StringBuilder errorMessage = new StringBuilder("An error occurred when trying to load Storage Accounts for the subscriptions:\n\n");
        for (Pair error : failedSubscriptions) {
            errorMessage.append(error.getKey()).append(": ").append(error.getValue()).append("\n");
        }
        DefaultLoader.getUIHelper().logError("An error occurred when trying to load Storage Accounts\n\n" + errorMessage.toString(), null);
    }
}
Also used : Azure(com.microsoft.azure.management.Azure) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ArrayList(java.util.ArrayList) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

ClientStorageAccount (com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)13 ExternalStorageNode (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.ExternalStorageNode)4 ExternalStorageAccountForm (com.microsoft.intellij.forms.ExternalStorageAccountForm)3 ArrayList (java.util.ArrayList)3 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)2 Gson (com.google.gson.Gson)1 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)1 HDStorageAccount (com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)1 Azure (com.microsoft.azure.management.Azure)1 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)1 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1 ExternalStorageAccountForm (com.microsoft.azuretools.azureexplorer.forms.ExternalStorageAccountForm)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 BlobContainer (com.microsoft.tooling.msservices.model.storage.BlobContainer)1 StorageModule (com.microsoft.tooling.msservices.serviceexplorer.azure.storage.StorageModule)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1