use of com.microsoft.azure.management.resources.fluentcore.arm.ResourceId in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidator method validateStorageAccount.
private void validateStorageAccount(AzureClient client, Set<Identity> identities, String location, CloudIdentityType cloudIdentityType, ValidationResultBuilder resultBuilder) {
AdlsGen2Config adlsGen2Config = adlsGen2ConfigGenerator.generateStorageConfig(location);
String storageAccountName = adlsGen2Config.getAccount();
Optional<String> storageAccountIdOptional = azureStorage.findStorageAccountIdInVisibleSubscriptions(client, storageAccountName);
if (storageAccountIdOptional.isEmpty()) {
LOGGER.debug("Storage account {} not found or insufficient permission to list subscriptions and / or storage accounts.", storageAccountName);
addError(resultBuilder, String.format("Storage account with name %s not found in the given Azure subscription. %s", storageAccountName, getAdviceMessage(STORAGE_LOCATION, cloudIdentityType)));
return;
}
List<RoleAssignmentInner> roleAssignments = client.listRoleAssignmentsByScopeInner(storageAccountIdOptional.get());
ResourceId storageAccountResourceId = ResourceId.fromString(storageAccountIdOptional.get());
boolean differentSubscriptions = !client.getCurrentSubscription().subscriptionId().equals(storageAccountResourceId.subscriptionId());
List<RoleAssignmentInner> roleAssignmentsForSubscription = getRoleAssignmentsOfSubscription(roleAssignments, storageAccountResourceId.subscriptionId(), client, differentSubscriptions);
for (Identity identity : identities) {
validateRoleAssigmentAndScope(roleAssignmentsForSubscription, resultBuilder, identity, List.of(storageAccountName, storageAccountResourceId.resourceGroupName(), storageAccountResourceId.subscriptionId()), differentSubscriptions, cloudIdentityType);
}
}
use of com.microsoft.azure.management.resources.fluentcore.arm.ResourceId in project azure-sdk-for-java by Azure.
the class ResourceIdTests method resourceIdForChildLevelResourceWorksFine.
@Test
public void resourceIdForChildLevelResourceWorksFine() {
ResourceId resourceId = ResourceId.fromString("/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/resourceGroupName/providers/Microsoft.Network/applicationGateways/something/someChildType/childName");
Assert.assertEquals(resourceId.name(), "childName");
Assert.assertEquals(resourceId.subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.resourceType(), "someChildType");
Assert.assertEquals(resourceId.fullResourceType(), "Microsoft.Network/applicationGateways/someChildType");
Assert.assertNotNull(resourceId.parent());
Assert.assertEquals(resourceId.parent().name(), "something");
Assert.assertEquals(resourceId.parent().subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.parent().resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.parent().name(), "something");
Assert.assertEquals(resourceId.parent().providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.parent().resourceType(), "applicationGateways");
Assert.assertEquals(resourceId.parent().fullResourceType(), "Microsoft.Network/applicationGateways");
}
use of com.microsoft.azure.management.resources.fluentcore.arm.ResourceId in project azure-sdk-for-java by Azure.
the class ResourceIdTests method resourceIdForTopLevelResourceWorksFine.
@Test
public void resourceIdForTopLevelResourceWorksFine() {
ResourceId resourceId = ResourceId.fromString("/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/resourceGroupName/providers/Microsoft.Network/applicationGateways/something");
Assert.assertEquals(resourceId.name(), "something");
Assert.assertEquals(resourceId.subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.resourceType(), "applicationGateways");
Assert.assertEquals(resourceId.fullResourceType(), "Microsoft.Network/applicationGateways");
Assert.assertNull(resourceId.parent());
}
use of com.microsoft.azure.management.resources.fluentcore.arm.ResourceId in project azure-sdk-for-java by Azure.
the class ResourceIdTests method resourceIdForGrandChildLevelResourceWorksFine.
@Test
public void resourceIdForGrandChildLevelResourceWorksFine() {
ResourceId resourceId = ResourceId.fromString("/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/resourceGroupName/providers/Microsoft.Network/applicationGateways/something/someChildType/childName/grandChildType/grandChild");
Assert.assertEquals(resourceId.name(), "grandChild");
Assert.assertEquals(resourceId.subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.resourceType(), "grandChildType");
Assert.assertEquals(resourceId.fullResourceType(), "Microsoft.Network/applicationGateways/someChildType/grandChildType");
Assert.assertNotNull(resourceId.parent());
Assert.assertEquals(resourceId.parent().name(), "childName");
Assert.assertEquals(resourceId.parent().subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.parent().resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.parent().providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.parent().resourceType(), "someChildType");
Assert.assertEquals(resourceId.parent().fullResourceType(), "Microsoft.Network/applicationGateways/someChildType");
Assert.assertNotNull(resourceId.parent().parent());
Assert.assertEquals(resourceId.parent().parent().name(), "something");
Assert.assertEquals(resourceId.parent().parent().subscriptionId(), "9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef");
Assert.assertEquals(resourceId.parent().parent().resourceGroupName(), "resourceGroupName");
Assert.assertEquals(resourceId.parent().parent().name(), "something");
Assert.assertEquals(resourceId.parent().parent().providerNamespace(), "Microsoft.Network");
Assert.assertEquals(resourceId.parent().parent().resourceType(), "applicationGateways");
Assert.assertEquals(resourceId.parent().parent().fullResourceType(), "Microsoft.Network/applicationGateways");
}
Aggregations