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();
}
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;
}
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;
}
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);
}
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);
}
Aggregations