use of com.microsoft.azure.arm.resources.ResourceId in project azure-maven-plugins by microsoft.
the class AbstractAppService method listPublishingProfileXmlWithSecrets.
@Override
public InputStream listPublishingProfileXmlWithSecrets() {
final ResourceId resourceId = ResourceId.fromString(id());
final String resourceName = StringUtils.equals(resourceId.resourceType(), "slots") ? String.format("%s/slots/%s", resourceId.parent().name(), resourceId.name()) : resourceId.name();
final CsmPublishingProfileOptions csmPublishingProfileOptions = new CsmPublishingProfileOptions().withFormat(PublishingProfileFormat.FTP);
return remote().manager().serviceClient().getWebApps().listPublishingProfileXmlWithSecrets(resourceId.resourceGroupName(), resourceName, csmPublishingProfileOptions);
}
use of com.microsoft.azure.arm.resources.ResourceId in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZoneValidatorServiceTest method testValidateWhenValidAndInvalidPrivateDnsZoneResourceId.
@Test
void testValidateWhenValidAndInvalidPrivateDnsZoneResourceId() {
ValidationResult.ValidationResultBuilder resultBuilder = new ValidationResult.ValidationResultBuilder();
ResourceId privateDnsZoneIdPostgres = getPrivateDnsZoneResourceId();
String privateDnsZoneIdStorage = "invalidPrivateDnsZoneId";
Map<AzurePrivateDnsZoneServiceEnum, String> serviceToPrivateDnsZoneId = Map.of(AzurePrivateDnsZoneServiceEnum.POSTGRES, privateDnsZoneIdPostgres.id(), AzurePrivateDnsZoneServiceEnum.STORAGE, privateDnsZoneIdStorage);
when(azurePrivateDnsZoneValidatorService.existingPrivateDnsZoneNameIsSupported(any(), any(), any())).thenAnswer(invocation -> {
ValidationResult.ValidationResultBuilder validationResultBuilder = invocation.getArgument(2);
ResourceId privateDnsZoneId = invocation.getArgument(1);
if (privateDnsZoneId.id().equals(privateDnsZoneIdStorage)) {
throw new InvalidParameterException();
}
return validationResultBuilder;
});
resultBuilder = underTest.validate(azureClient, NETWORK_RESOURCE_GROUP_NAME, NETWORK_NAME, serviceToPrivateDnsZoneId, resultBuilder);
ValidationTestUtil.checkErrorsPresent(resultBuilder, List.of("The provided private DNS zone id invalidPrivateDnsZoneId for service " + "Microsoft.Storage/storageAccounts is not a valid azure resource id."));
verify(azurePrivateDnsZoneValidatorService).existingPrivateDnsZoneNameIsSupported(eq(AzurePrivateDnsZoneServiceEnum.POSTGRES), any(), eq(resultBuilder));
verify(azurePrivateDnsZoneValidatorService).privateDnsZoneExists(eq(azureClient), any(), eq(resultBuilder));
verify(azurePrivateDnsZoneValidatorService).privateDnsZoneConnectedToNetwork(eq(azureClient), eq(NETWORK_RESOURCE_GROUP_NAME), eq(NETWORK_NAME), any(), eq(resultBuilder));
verify(azurePrivateDnsZoneValidatorService, never()).existingPrivateDnsZoneNameIsSupported(eq(AzurePrivateDnsZoneServiceEnum.STORAGE), any(), any());
}
use of com.microsoft.azure.arm.resources.ResourceId in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZoneValidatorService method validate.
public ValidationResult.ValidationResultBuilder validate(AzureClient azureClient, String networkResourceGroupName, String networkName, Map<AzurePrivateDnsZoneServiceEnum, String> serviceToPrivateDnsZoneId, ValidationResult.ValidationResultBuilder resultBuilder) {
serviceToPrivateDnsZoneId.forEach((service, privateDnsZoneId) -> {
try {
ResourceId privateDnsZoneResourceId = ResourceId.fromString(privateDnsZoneId);
azurePrivateDnsZoneValidatorService.existingPrivateDnsZoneNameIsSupported(service, privateDnsZoneResourceId, resultBuilder);
azurePrivateDnsZoneValidatorService.privateDnsZoneExists(azureClient, privateDnsZoneResourceId, resultBuilder);
azurePrivateDnsZoneValidatorService.privateDnsZoneConnectedToNetwork(azureClient, networkResourceGroupName, networkName, privateDnsZoneResourceId, resultBuilder);
} catch (InvalidParameterException e) {
String validationMessage = String.format("The provided private DNS zone id %s for service %s is not a valid azure resource id.", privateDnsZoneId, service.getResourceType());
LOGGER.warn(validationMessage);
resultBuilder.error(validationMessage);
}
});
return resultBuilder;
}
use of com.microsoft.azure.arm.resources.ResourceId in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZoneValidatorServiceTest method testValidate.
@Test
void testValidate() {
ValidationResult.ValidationResultBuilder resultBuilder = new ValidationResult.ValidationResultBuilder();
ResourceId privateDnsZoneId = getPrivateDnsZoneResourceId();
Map<AzurePrivateDnsZoneServiceEnum, String> serviceToPrivateDnsZoneId = Map.of(AzurePrivateDnsZoneServiceEnum.POSTGRES, privateDnsZoneId.id());
resultBuilder = underTest.validate(azureClient, NETWORK_RESOURCE_GROUP_NAME, NETWORK_NAME, serviceToPrivateDnsZoneId, resultBuilder);
assertFalse(resultBuilder.build().hasError());
verify(azurePrivateDnsZoneValidatorService).existingPrivateDnsZoneNameIsSupported(eq(AzurePrivateDnsZoneServiceEnum.POSTGRES), any(), eq(resultBuilder));
verify(azurePrivateDnsZoneValidatorService).privateDnsZoneExists(eq(azureClient), any(), eq(resultBuilder));
verify(azurePrivateDnsZoneValidatorService).privateDnsZoneConnectedToNetwork(eq(azureClient), eq(NETWORK_RESOURCE_GROUP_NAME), eq(NETWORK_NAME), any(), eq(resultBuilder));
}
Aggregations