public static List<String> getResourceGroups(Azure azureClient) { List<String> result = new ArrayList<>(); if (azureClient != null) { for (ResourceGroup resourceGroup : azureClient.resourceGroups().list()) { result.add(resourceGroup.name()); } } return result; }
@Override public Observable<Deployment> listAsync() { return this.manager().resourceGroups().listAsync().flatMap(new Func1<ResourceGroup, Observable<Deployment>>() { @Override public Observable<Deployment> call(ResourceGroup resourceGroup) { return listByResourceGroupAsync(resourceGroup.name()); } }); }
@Override public DeploymentImpl withNewResourceGroup(String resourceGroupName, Region region) { this.creatableResourceGroup = this.resourceManager.resourceGroups() .define(resourceGroupName) .withRegion(region); this.addDependency(this.creatableResourceGroup); this.resourceGroupName = resourceGroupName; return this; }
@TaskAction public void deleteResourceGroup() { String rgName = resourceGroupName.get(); if (getClient().resourceGroups().contain(rgName)) { getClient().resourceGroups().deleteByName(rgName); getLogger().info("ResourceGroup " + rgName + " deleted"); } } }
Region region = Region.US_SOUTH_CENTRAL; resourceGroups.define(rgName) .withRegion(Region.US_SOUTH_CENTRAL) .withTag("department", "finance") for (ResourceGroup rg : resourceGroups.listByTag("department", "finance")) { if (rg.name().equals(rgName)) { groupResult = rg; Assert.assertTrue(resourceGroups.checkExistence(rgName)); ResourceGroup getGroup = resourceGroups.getByName(rgName); Assert.assertNotNull(getGroup); Assert.assertEquals(rgName, getGroup.name()); Assert.assertTrue(region.name().equalsIgnoreCase(getGroup.regionName())); resourceGroups.deleteByName(rgName); Assert.assertFalse(resourceGroups.checkExistence(rgName));
@Override public ResourceGroup internalGet(String key) { return azure.resourceGroups().getByName(key); }
protected boolean isResourceGroupExist(final String resourceGroup) throws Exception { return getAzureClient().resourceGroups().contain(resourceGroup); }
public static boolean canCreateNewResGrp(Azure azure, String resGrpName) { return (!azure.resourceGroups().checkExistence(resGrpName)); } }
/** * Get Resource Group by Subscription ID and Resource Group name. */ public ResourceGroup getResourceGroupBySubscriptionIdAndName(String sid, String name) throws Exception { ResourceGroup resourceGroup; Azure azure = AuthMethodManager.getInstance().getAzureClient(sid); try { resourceGroup = azure.resourceGroups().getByName(name); if (resourceGroup == null) { throw new Exception(CANNOT_GET_RESOURCE_GROUP); } } catch (Exception e) { throw new Exception(CANNOT_GET_RESOURCE_GROUP); } return resourceGroup; }
public static WithCreate defineWindowsApp(final String resourceGroup, final String appName, final Azure azureClient, final AppServicePlan plan) throws Exception { assureWindowsPlan(plan); final ExistingWindowsPlanWithGroup existingWindowsPlanWithGroup = azureClient.webApps() .define(appName).withExistingWindowsPlan(plan); return azureClient.resourceGroups().contain(resourceGroup) ? existingWindowsPlanWithGroup.withExistingResourceGroup(resourceGroup) : existingWindowsPlanWithGroup.withNewResourceGroup(resourceGroup); }
/** * List Resource Group by Subscription ID. * * @param sid subscription Id * @return List of ResourceGroup instances */ public List<ResourceGroup> getResourceGroupsBySubscriptionId(String sid) { List<ResourceGroup> ret = new ArrayList<>(); try { Azure azure = AuthMethodManager.getInstance().getAzureClient(sid); ret.addAll(azure.resourceGroups().list()); } catch (IOException e) { e.printStackTrace(); } return ret; }
@Override public Observable<Deployment> listAsync() { return this.manager().resourceGroups().listAsync().flatMap(new Func1<ResourceGroup, Observable<Deployment>>() { @Override public Observable<Deployment> call(ResourceGroup resourceGroup) { return listByResourceGroupAsync(resourceGroup.name()); } }); }
@Override public DeploymentImpl withNewResourceGroup(String resourceGroupName, Region region) { this.creatableResourceGroup = this.resourceManager.resourceGroups() .define(resourceGroupName) .withRegion(region); this.addDependency(this.creatableResourceGroup); this.resourceGroupName = resourceGroupName; return this; }
genericResources.moveResources(rgName, resourceGroups.getByName(newRgName), Arrays.asList(resource.id())); Assert.assertFalse(genericResources.checkExistence(rgName, resource.resourceProviderNamespace(), resource.parentResourcePath(), resource.resourceType(), resource.name(), resource.apiVersion())); resource = genericResources.get(newRgName, resource.resourceProviderNamespace(), resource.parentResourcePath(), resource.resourceType(), resource.name(), resource.apiVersion());
public static WithDockerContainerImage defineLinuxApp(final String resourceGroup, final String appName, final Azure azureClient, final AppServicePlan plan) throws Exception { assureLinuxPlan(plan); final ExistingLinuxPlanWithGroup existingLinuxPlanWithGroup = azureClient.webApps() .define(appName).withExistingLinuxPlan(plan); return azureClient.resourceGroups().contain(resourceGroup) ? existingLinuxPlanWithGroup.withExistingResourceGroup(resourceGroup) : existingLinuxPlanWithGroup.withNewResourceGroup(resourceGroup); }
@Override public PagedList<LocalNetworkGateway> list() { return new GroupPagedList<LocalNetworkGateway>(this.manager().resourceManager().resourceGroups().list()) { @Override public List<LocalNetworkGateway> listNextGroup(String resourceGroupName) { return wrapList(LocalNetworkGatewaysImpl.this.inner().listByResourceGroup(resourceGroupName)); } }; }
@Override public Observable<VirtualNetworkGatewayConnection> listAsync() { return this.manager().resourceManager().resourceGroups().listAsync() .flatMap(new Func1<ResourceGroup, Observable<VirtualNetworkGatewayConnection>>() { @Override public Observable<VirtualNetworkGatewayConnection> call(ResourceGroup resourceGroup) { return wrapPageAsync(inner().listByResourceGroupAsync(resourceGroup.name())); } }); }
@Override public ResourceGroup internalCreate(String key) { return azure.resourceGroups().define(key).withRegion(azureProperties.getRegion()).create(); } }
= azure.resourceGroups().contain(servicePlanResGrp) ? withGroup.withExistingResourceGroup(servicePlanResGrp) : withGroup.withNewResourceGroup(servicePlanResGrp);