use of com.azure.resourcemanager.storage.models.CheckNameAvailabilityResult in project azure-maven-plugins by microsoft.
the class AzureStorageAccount method checkNameAvailability.
public CheckNameAvailabilityResultEntity checkNameAvailability(String subscriptionId, String name) {
StorageManager manager = StorageManagerFactory.create(subscriptionId);
CheckNameAvailabilityResult result = manager.storageAccounts().checkNameAvailability(name);
return new CheckNameAvailabilityResultEntity(result.isAvailable(), Optional.ofNullable(result.reason()).map(Reason::toString).orElse(null), result.message());
}
use of com.azure.resourcemanager.storage.models.CheckNameAvailabilityResult in project azure-vm-agents-plugin by jenkinsci.
the class AzureVMManagementServiceDelegate method verifyStorageAccountName.
public String verifyStorageAccountName(String resourceGroupName, String storageAccountName, String storageAccountType) {
boolean isAvailable = false;
try {
if (StringUtils.isBlank(storageAccountType)) {
return Messages.Azure_GC_Template_SA_Type_Null_Or_Empty();
}
CheckNameAvailabilityResult checkResult = azureClient.storageAccounts().checkNameAvailability(storageAccountName);
isAvailable = checkResult.isAvailable();
if (!isAvailable && Reason.ACCOUNT_NAME_INVALID.equals(checkResult.reason())) {
return Messages.Azure_GC_Template_SA_Not_Valid();
} else if (!isAvailable) {
/*if it's not available we need to check if it's already in our resource group*/
StorageAccount checkAccount = azureClient.storageAccounts().getByResourceGroup(resourceGroupName, storageAccountName);
if (null == checkAccount) {
return Messages.Azure_GC_Template_SA_Already_Exists();
} else {
/*if the storage account is already in out resource group, check whether they are the same type*/
if (checkAccount.skuType().name().toString().equalsIgnoreCase(storageAccountType)) {
return Constants.OP_SUCCESS;
} else {
return Messages.Azure_GC_Template_SA_Type_Not_Match(storageAccountType, checkAccount.skuType().name().toString());
}
}
} else {
return Constants.OP_SUCCESS;
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Verification failed for storage account name", e);
return Messages.Azure_GC_Template_SA_Already_Exists();
}
}
Aggregations