Search in sources :

Example 1 with ResourceId

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);
}
Also used : ResourceId(com.microsoft.azure.arm.resources.ResourceId) CsmPublishingProfileOptions(com.azure.resourcemanager.appservice.models.CsmPublishingProfileOptions)

Example 2 with ResourceId

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());
}
Also used : InvalidParameterException(java.security.InvalidParameterException) PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId) ResourceId(com.microsoft.azure.arm.resources.ResourceId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) Test(org.junit.jupiter.api.Test)

Example 3 with ResourceId

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;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) ResourceId(com.microsoft.azure.arm.resources.ResourceId)

Example 4 with ResourceId

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));
}
Also used : PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId(com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId) ResourceId(com.microsoft.azure.arm.resources.ResourceId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) AzurePrivateDnsZoneServiceEnum(com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceId (com.microsoft.azure.arm.resources.ResourceId)4 AzurePrivateDnsZoneServiceEnum (com.sequenceiq.cloudbreak.cloud.azure.AzurePrivateDnsZoneServiceEnum)2 PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId (com.sequenceiq.cloudbreak.cloud.azure.validator.privatedns.PrivateDnsZoneValidationTestConstants.getPrivateDnsZoneResourceId)2 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 InvalidParameterException (java.security.InvalidParameterException)2 Test (org.junit.jupiter.api.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CsmPublishingProfileOptions (com.azure.resourcemanager.appservice.models.CsmPublishingProfileOptions)1