use of com.azure.resourcemanager.redis.models.CheckNameAvailabilityParameters in project azure-maven-plugins by microsoft.
the class AzureRedis method checkNameAvailability.
@AzureOperation(name = "redis.check_name", params = "name", type = AzureOperation.Type.SERVICE)
public CheckNameAvailabilityResultEntity checkNameAvailability(String subscriptionId, String name) {
final RedisManager redisManager = RedisManagerFactory.create(subscriptionId);
RedisClient redis = redisManager.redisCaches().manager().serviceClient().getRedis();
try {
redis.checkNameAvailability(new CheckNameAvailabilityParameters().withName(name).withType("Microsoft.Cache/redis"));
return new CheckNameAvailabilityResultEntity(true, null);
} catch (ManagementException ex) {
ManagementError value = ex.getValue();
if (value != null && "NameNotAvailable".equals(value.getCode())) {
return new CheckNameAvailabilityResultEntity(false, String.format("The name '%s' for Redis Cache is not available", name), value.getMessage());
}
throw ex;
}
}
Aggregations