Search in sources :

Example 1 with RedisCaches

use of com.microsoft.azure.management.redis.RedisCaches in project azure-tools-for-java by Microsoft.

the class AzureRedisMvpModel method getRedisCaches.

/**
 * Get all redis caches.
 * @return A map containing RedisCaches with subscription id as the key
 */
public HashMap<String, RedisCaches> getRedisCaches() {
    HashMap<String, RedisCaches> redisCacheMaps = new HashMap<>();
    List<Subscription> subscriptions = az(AzureAccount.class).account().getSelectedSubscriptions();
    for (Subscription subscription : subscriptions) {
        Azure azure = AuthMethodManager.getInstance().getAzureClient(subscription.getId());
        if (azure.redisCaches() == null) {
            continue;
        }
        redisCacheMaps.put(subscription.getId(), azure.redisCaches());
    }
    return redisCacheMaps;
}
Also used : Azure(com.microsoft.azure.management.Azure) RedisCaches(com.microsoft.azure.management.redis.RedisCaches) HashMap(java.util.HashMap) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 2 with RedisCaches

use of com.microsoft.azure.management.redis.RedisCaches in project azure-tools-for-java by Microsoft.

the class AzureRedisMvpModel method getRedisCache.

/**
 * Get a Redis Cache by Id.
 * @param sid Subscription Id
 * @param id Redis cache's id
 * @return Redis Cache Object
 */
public RedisCache getRedisCache(String sid, String id) {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    RedisCaches redisCaches = azure.redisCaches();
    if (redisCaches == null) {
        return null;
    }
    return redisCaches.getById(id);
}
Also used : Azure(com.microsoft.azure.management.Azure) RedisCaches(com.microsoft.azure.management.redis.RedisCaches)

Example 3 with RedisCaches

use of com.microsoft.azure.management.redis.RedisCaches in project azure-tools-for-java by Microsoft.

the class RedisCacheCreatorScenario method setUp.

@Before
public void setUp() throws Exception {
    RedisCaches redisCaches = mock(RedisCaches.class);
    redisCacheCreator = new RedisCacheCreator(redisCaches, DNS_NAME, REGION_NAME, GROUP_NAME);
    creatorMap = redisCacheCreator.CreatorMap();
}
Also used : RedisCaches(com.microsoft.azure.management.redis.RedisCaches) Before(cucumber.api.java.Before)

Example 4 with RedisCaches

use of com.microsoft.azure.management.redis.RedisCaches in project azure-tools-for-java by Microsoft.

the class AzureRedisMvpModel method deleteRedisCache.

/**
 * Delete a redis cache.
 * @param sid Subscription Id
 * @param id Redis cache's id
 */
public void deleteRedisCache(String sid, String id) {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    RedisCaches redisCaches = azure.redisCaches();
    if (redisCaches == null) {
        return;
    }
    redisCaches.deleteById(id);
}
Also used : Azure(com.microsoft.azure.management.Azure) RedisCaches(com.microsoft.azure.management.redis.RedisCaches)

Example 5 with RedisCaches

use of com.microsoft.azure.management.redis.RedisCaches in project azure-tools-for-java by Microsoft.

the class RedisCacheModulePresenter method onModuleRefresh.

/**
 * Called from view when the view needs refresh.
 */
public void onModuleRefresh() {
    final HashMap<String, ArrayList<NodeContent>> nodeMap = new HashMap<>();
    final HashMap<String, RedisCaches> redisCachesMap = azureRedisMvpModel.getRedisCaches();
    for (final String sid : redisCachesMap.keySet()) {
        final ArrayList<NodeContent> nodeContentList = new ArrayList<>();
        for (final RedisCache redisCache : redisCachesMap.get(sid).list()) {
            nodeContentList.add(new NodeContent(redisCache.id(), redisCache.name(), redisCache.provisioningState()));
        }
        nodeMap.put(sid, nodeContentList);
    }
    getMvpView().showNode(nodeMap);
}
Also used : RedisCache(com.microsoft.azure.management.redis.RedisCache) RedisCaches(com.microsoft.azure.management.redis.RedisCaches) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NodeContent(com.microsoft.azuretools.core.mvp.ui.base.NodeContent)

Aggregations

RedisCaches (com.microsoft.azure.management.redis.RedisCaches)6 Azure (com.microsoft.azure.management.Azure)3 HashMap (java.util.HashMap)2 RedisCache (com.microsoft.azure.management.redis.RedisCache)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 NodeContent (com.microsoft.azuretools.core.mvp.ui.base.NodeContent)1 Before (cucumber.api.java.Before)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1