Search in sources :

Example 61 with Azure

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

the class CreateFunctionAction method getEventHubNamespaceConnectionString.

private String getEventHubNamespaceConnectionString(EventHubNamespace eventHubNamespace) {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(eventHubNamespace.id().split("/")[2]);
    EventHubNamespaceAuthorizationRule eventHubNamespaceAuthorizationRule = azure.eventHubNamespaces().authorizationRules().getByName(eventHubNamespace.resourceGroupName(), eventHubNamespace.name(), "RootManageSharedAccessKey");
    return eventHubNamespaceAuthorizationRule.getKeys().primaryConnectionString();
}
Also used : Azure(com.microsoft.azure.management.Azure) EventHubNamespaceAuthorizationRule(com.microsoft.azure.management.eventhub.EventHubNamespaceAuthorizationRule)

Example 62 with Azure

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

the class AzureMvpModel method getDeploymentByRgName.

/**
 * Get deployment by resource group name
 * @param rgName
 * @return
 */
@AzureOperation(name = "arm|deployment.list.subscription|rg", params = { "rgName", "sid" }, type = AzureOperation.Type.SERVICE)
public List<ResourceEx<Deployment>> getDeploymentByRgName(String sid, String rgName) {
    List<ResourceEx<Deployment>> res = new ArrayList<>();
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    res.addAll(azure.deployments().listByResourceGroup(rgName).stream().map(deployment -> new ResourceEx<>(deployment, sid)).collect(Collectors.toList()));
    Collections.sort(res, getComparator((ResourceEx<Deployment> deploymentResourceEx) -> deploymentResourceEx.getResource().name()));
    return res;
}
Also used : Azure(com.microsoft.azure.management.Azure) ArrayList(java.util.ArrayList) Deployment(com.microsoft.azure.management.resources.Deployment) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 63 with Azure

use of com.microsoft.azure.management.Azure 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 64 with Azure

use of com.microsoft.azure.management.Azure 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 65 with Azure

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

the class RedisExplorerIntegrationTest method initialize.

@Override
protected void initialize(RestClient restClient, String defaultSubscription, String domain) throws Exception {
    Azure.Authenticated azureAuthed = Azure.authenticate(restClient, defaultSubscription, domain);
    azure = azureAuthed.withSubscription(defaultSubscription);
    this.defaultSubscription = defaultSubscription;
    Set<String> sidList = Stream.of(defaultSubscription).collect(Collectors.toSet());
    PowerMockito.mockStatic(AuthMethodManager.class);
    when(AuthMethodManager.getInstance()).thenReturn(authMethodManagerMock);
    when(authMethodManagerMock.getAzureManager()).thenReturn(azureManagerMock);
    when(azureManagerMock.getAzure(anyString())).thenReturn(azure);
    when(azureManagerMock.getSubscriptionManager()).thenReturn(subscriptionManagerMock);
    PowerMockito.mockStatic(DefaultLoader.class);
    when(DefaultLoader.getUIHelper()).thenReturn(uiHelper);
    String redisCacheQueryString = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Cache/Redis/%s";
    redisID = String.format(redisCacheQueryString, defaultSubscription, RESOURCE_GROUP, REDIS_NAME);
}
Also used : Azure(com.microsoft.azure.management.Azure) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Aggregations

Azure (com.microsoft.azure.management.Azure)144 File (java.io.File)75 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 ExecutorService (java.util.concurrent.ExecutorService)17 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)16 DiskService (com.vmware.photon.controller.model.resources.DiskService)16 ComputeEnumerateResourceRequest (com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest)15 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)15 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)15 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)15 AzureResourceType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType)15 AzureConstants.getQueryResultLimit (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.getQueryResultLimit)15 AzureDeferredResultServiceCallback (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback)15 Default (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default)15 AzureSdkClients (com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients)15 AzureUtils (com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils)15 AzureUtils.getResourceGroupName (com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getResourceGroupName)15 AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)15 ComputeEnumerateAdapterRequest (com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest)15