use of com.azure.resourcemanager.resources.ResourceManager in project terra-workspace-manager by DataBiosphere.
the class ValidateMRGStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException {
AzureCloudContext azureCloudContext = flightContext.getInputParameters().get(JobMapKeys.REQUEST.getKeyName(), AzureCloudContext.class);
try {
ResourceManager resourceManager = crlService.getResourceManager(azureCloudContext, azureConfig);
resourceManager.resourceGroups().getByName(azureCloudContext.getAzureResourceGroupId());
} catch (Exception azureError) {
throw new CloudContextRequiredException("Invalid Azure cloud context", azureError);
}
return StepResult.getStepResultSuccess();
}
use of com.azure.resourcemanager.resources.ResourceManager in project terra-workspace-manager by DataBiosphere.
the class CrlService method buildResourceManager.
/**
* Get a resource manager pointed at the MRG subscription
*
* @param azureCloudContext target cloud context
* @return azure resource manager
*/
public ResourceManager buildResourceManager(AzureCloudContext azureCloudContext, AzureConfiguration azureConfig) {
TokenCredential azureCreds = getManagedAppCredentials(azureConfig);
AzureProfile azureProfile = new AzureProfile(azureCloudContext.getAzureTenantId(), azureCloudContext.getAzureSubscriptionId(), AzureEnvironment.AZURE);
// We must use FQDN because there are two `Defaults` symbols imported otherwise.
ResourceManager manager = bio.terra.cloudres.azure.resourcemanager.common.Defaults.crlConfigure(clientConfig, ResourceManager.configure()).authenticate(azureCreds, azureProfile).withSubscription(azureCloudContext.getAzureSubscriptionId());
return manager;
}
use of com.azure.resourcemanager.resources.ResourceManager in project azure-maven-plugins by microsoft.
the class AzureService method listSupportedRegions.
default List<Region> listSupportedRegions(String subscriptionId) {
String[] names = StringUtils.split(name(), "/");
if (names.length != 2) {
throw new AzureToolkitRuntimeException(String.format("It is illegal to list regions for service '%s'.", name()));
}
final String provider = names[0];
final String resourceType = names[1];
List<Region> allRegionList = az(IAzureAccount.class).listRegions(subscriptionId);
List<Region> result = new ArrayList<>();
final ResourceManager resourceManager = getResourceManager(subscriptionId);
resourceManager.providers().getByName(provider).resourceTypes().stream().filter(type -> StringUtils.equalsIgnoreCase(type.resourceType(), resourceType)).findAny().map(ProviderResourceType::locations).ifPresent(list -> result.addAll(list.stream().map(Region::fromName).filter(allRegionList::contains).collect(Collectors.toList())));
return result.isEmpty() ? allRegionList : result;
}
Aggregations