Search in sources :

Example 1 with ResourceNameAvailabilityInner

use of com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner in project azure-tools-for-java by Microsoft.

the class ValidationUtils method validateAppServiceName.

public static void validateAppServiceName(String subscriptionId, String appServiceName) {
    final Pair<String, String> cacheKey = Pair.of(subscriptionId, appServiceName);
    if (appServiceNameValidationCache.containsKey(cacheKey)) {
        throwCachedValidationResult(appServiceNameValidationCache.get(cacheKey));
        return;
    }
    if (StringUtils.isEmpty(subscriptionId)) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, message("appService.subscription.validate.empty"));
    }
    if (!isValidAppServiceName(appServiceName)) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, message("appService.subscription.validate.invalidName"));
    }
    final ResourceNameAvailabilityInner result = Azure.az(AzureAppService.class).getAppServiceManager(subscriptionId).webApps().manager().serviceClient().getResourceProviders().checkNameAvailability(appServiceName, CheckNameResourceTypes.MICROSOFT_WEB_SITES);
    if (!result.nameAvailable()) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, result.message());
    }
    appServiceNameValidationCache.put(cacheKey, null);
}
Also used : ResourceNameAvailabilityInner(com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner)

Example 2 with ResourceNameAvailabilityInner

use of com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner in project azure-maven-plugins by microsoft.

the class AzureAppService method checkNameAvailability.

@AzureOperation(name = "appservice.check_name", params = "name", type = AzureOperation.Type.SERVICE)
public CheckNameAvailabilityResultEntity checkNameAvailability(String subscriptionId, String name) {
    final AppServiceManager azureResourceManager = getAppServiceManager(subscriptionId);
    final ResourceNameAvailabilityInner result = azureResourceManager.webApps().manager().serviceClient().getResourceProviders().checkNameAvailability(name, CheckNameResourceTypes.MICROSOFT_WEB_SITES);
    return new CheckNameAvailabilityResultEntity(result.nameAvailable(), result.reason().toString(), result.message());
}
Also used : AppServiceManager(com.azure.resourcemanager.appservice.AppServiceManager) ResourceNameAvailabilityInner(com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner) CheckNameAvailabilityResultEntity(com.microsoft.azure.toolkit.lib.common.entity.CheckNameAvailabilityResultEntity) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 3 with ResourceNameAvailabilityInner

use of com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner in project azure-tools-for-java by microsoft.

the class ValidationUtils method validateAppServiceName.

public static void validateAppServiceName(String subscriptionId, String appServiceName) {
    final Pair<String, String> cacheKey = Pair.of(subscriptionId, appServiceName);
    if (appServiceNameValidationCache.containsKey(cacheKey)) {
        throwCachedValidationResult(appServiceNameValidationCache.get(cacheKey));
        return;
    }
    if (StringUtils.isEmpty(subscriptionId)) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, message("appService.subscription.validate.empty"));
    }
    if (!isValidAppServiceName(appServiceName)) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, message("appService.subscription.validate.invalidName"));
    }
    final ResourceNameAvailabilityInner result = Azure.az(AzureAppService.class).getAppServiceManager(subscriptionId).webApps().manager().serviceClient().getResourceProviders().checkNameAvailability(appServiceName, CheckNameResourceTypes.MICROSOFT_WEB_SITES);
    if (!result.nameAvailable()) {
        cacheAndThrow(appServiceNameValidationCache, cacheKey, result.message());
    }
    appServiceNameValidationCache.put(cacheKey, null);
}
Also used : ResourceNameAvailabilityInner(com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner)

Aggregations

ResourceNameAvailabilityInner (com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner)3 AppServiceManager (com.azure.resourcemanager.appservice.AppServiceManager)1 CheckNameAvailabilityResultEntity (com.microsoft.azure.toolkit.lib.common.entity.CheckNameAvailabilityResultEntity)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1