From 723e8a3d66c98b75d22540dba60014515616a44a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jun 2016 08:32:27 -0700 Subject: [PATCH 01/20] making Manager generic to start exposing common method implementations that return a specific *Manager --- .../management/compute/implementation/ComputeManager.java | 2 +- .../management/network/implementation/NetworkManager.java | 2 +- .../resources/fluentcore/arm/implementation/Manager.java | 3 ++- .../management/storage/implementation/StorageManager.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ComputeManager.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ComputeManager.java index 4c2069028c62..9835bd9d6d73 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ComputeManager.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/ComputeManager.java @@ -16,7 +16,7 @@ /** * Entry point to Azure compute resource management. */ -public final class ComputeManager extends Manager { +public final class ComputeManager extends Manager { // The service managers private StorageManager storageManager; private NetworkManager networkManager; diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManager.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManager.java index 6e7799be4959..a0dfceff214f 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManager.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkManager.java @@ -20,7 +20,7 @@ /** * Entry point to Azure network management. */ -public final class NetworkManager extends Manager { +public final class NetworkManager extends Manager { private final NetworkManagementClientImpl networkManagementClient; // Collections diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/implementation/Manager.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/implementation/Manager.java index 585886b53927..60aca989b2e4 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/implementation/Manager.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/implementation/Manager.java @@ -11,8 +11,9 @@ /** * Base class for Azure resource managers. + * @param specific manager type */ -public abstract class Manager { +public abstract class Manager { private final ResourceManager resourceManager; diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageManager.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageManager.java index 2011fd965820..a254ea447e5b 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageManager.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageManager.java @@ -19,7 +19,7 @@ /** * Entry point to Azure storage resource management. */ -public final class StorageManager extends Manager { +public final class StorageManager extends Manager { private final StorageManagementClientImpl storageManagementClient; // Collections From c975f348dee10fcfec435b76a9c01118c0ddedd9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 13:26:43 -0700 Subject: [PATCH 02/20] renaming SupportsGettingByName#get() as getByName(); adding SupportsGettingById --- .../resources/DeploymentOperations.java | 4 +-- .../arm/collection/SupportsGettingById.java | 30 +++++++++++++++++++ .../arm/collection/SupportsGettingByName.java | 4 +-- .../DeploymentOperationsImpl.java | 2 +- .../implementation/DeploymentsImpl.java | 2 +- .../FeaturesInResourceProviderImpl.java | 2 +- .../implementation/ProvidersImpl.java | 2 +- .../implementation/ResourceGroupsImpl.java | 2 +- .../implementation/SubscriptionsImpl.java | 2 +- .../resources/DeploymentsTests.java | 2 +- .../resources/GenericResourcesTests.java | 4 +-- .../resources/ResourceGroupsTests.java | 2 +- .../samples/ManageAvailabilitySet.java | 2 +- .../compute/samples/ManageVirtualMachine.java | 2 +- .../storage/samples/ManageStorageAccount.java | 2 +- 15 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperations.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperations.java index 99c565b03754..065d71b6496c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperations.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/DeploymentOperations.java @@ -6,7 +6,7 @@ package com.microsoft.azure.management.resources; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; /** @@ -14,5 +14,5 @@ */ public interface DeploymentOperations extends SupportsListing, - SupportsGettingByName { + SupportsGettingById { } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java new file mode 100644 index 000000000000..f89d1e4530b4 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingById.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + + +package com.microsoft.azure.management.resources.fluentcore.arm.collection; + +import com.microsoft.azure.CloudException; + +import java.io.IOException; + +/** + * Provides access to getting a specific Azure resource based on its resource ID. + * + * @param the type of the resource collection + */ +public interface SupportsGettingById { + /** + * Gets the information about a resource from Azure based on the resource id. + * + * @param id the id of the resource. + * @return an immutable representation of the resource + * @throws CloudException exceptions thrown from the cloud + * @throws IOException exceptions thrown from serialization/deserialization + * @throws IllegalArgumentException exceptions thrown when something is wrong with the input parameters + */ + T getById(String id) throws CloudException, IllegalArgumentException, IOException; +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java index f227cf266e36..2744189d2182 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByName.java @@ -12,7 +12,7 @@ import java.io.IOException; /** - * Provides access to getting a specific Azure resource based on its name with the current resource group. + * Provides access to getting a specific Azure resource based on its name within the current resource group. * * @param the type of the resource collection */ @@ -25,5 +25,5 @@ public interface SupportsGettingByName { * @throws CloudException exceptions thrown from the cloud * @throws IOException exceptions thrown from serialization/deserialization */ - T get(String name) throws CloudException, IOException; + T getByName(String name) throws CloudException, IOException; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java index 63d9ad37736a..62e6c24286d0 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentOperationsImpl.java @@ -44,7 +44,7 @@ public PagedList list() throws CloudException, IOException } @Override - public DeploymentOperation get(String operationId) throws IOException, CloudException { + public DeploymentOperation getById(String operationId) throws CloudException, IllegalArgumentException, IOException { return createFluentModel(client.get(deployment.resourceGroupName(), deployment.name(), operationId).getBody()); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index 9dc445de858f..a7c048ba423a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -63,7 +63,7 @@ public PagedList listByGroup(String groupName) throws CloudException } @Override - public Deployment get(String name) throws IOException, CloudException { + public Deployment getByName(String name) throws IOException, CloudException { for (ResourceGroup group : this.resourceManager.resourceGroups().list()) { try { DeploymentExtendedInner inner = client.get(group.name(), name).getBody(); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java index 2732b2763971..e9c54bfd3904 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/FeaturesInResourceProviderImpl.java @@ -46,7 +46,7 @@ public Feature register(String featureName) throws IOException, CloudException { } @Override - public Feature get(String name) throws CloudException, IOException { + public Feature getByName(String name) throws CloudException, IOException { return new FeatureImpl(client.get(resourceProviderNamespace, name).getBody()); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java index 9fa9f66fab81..b110a17cfffe 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ProvidersImpl.java @@ -49,7 +49,7 @@ public Provider register(String resourceProviderNamespace) throws CloudException } @Override - public Provider get(String resourceProviderNamespace) throws CloudException, IOException { + public Provider getByName(String resourceProviderNamespace) throws CloudException, IOException { return new ProviderImpl(client.get(resourceProviderNamespace).getBody()); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java index 2f1d4d9f70ee..09c1e8642e9e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/ResourceGroupsImpl.java @@ -47,7 +47,7 @@ public ResourceGroup typeConvert(ResourceGroupInner resourceGroupInner) { } @Override - public ResourceGroupImpl get(String name) throws CloudException, IOException { + public ResourceGroupImpl getByName(String name) throws CloudException, IOException { ResourceGroupInner resourceGroupInner = client.get(name).getBody(); return createFluentModel(resourceGroupInner); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java index 6741a3708c32..43b8cd0e18a7 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionsImpl.java @@ -40,7 +40,7 @@ public Subscription typeConvert(SubscriptionInner subscriptionInner) { @Override // Gets a specific resource group - public SubscriptionImpl get(String name) throws CloudException, IOException { + public SubscriptionImpl getByName(String name) throws CloudException, IOException { SubscriptionInner subscription = client.get(name).getBody(); return new SubscriptionImpl(subscription, client); } diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/DeploymentsTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/DeploymentsTests.java index 6afc3309d391..b9786302d1d9 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/DeploymentsTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/DeploymentsTests.java @@ -72,7 +72,7 @@ public void canDeployVirtualNetwork() throws Exception { // Deployment operations List operations = deployment.deploymentOperations().list(); Assert.assertEquals(2, operations.size()); - DeploymentOperation op = deployment.deploymentOperations().get(operations.get(0).operationId()); + DeploymentOperation op = deployment.deploymentOperations().getById(operations.get(0).operationId()); Assert.assertNotNull(op); resourceClient.genericResources().delete(rgName, "Microsoft.Network", "", "virtualnetworks", "VNet1", "2015-06-15"); } diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GenericResourcesTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GenericResourcesTests.java index 4d752dd38756..b744f0ca405c 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GenericResourcesTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/GenericResourcesTests.java @@ -30,7 +30,7 @@ public static void setup() throws Exception { resourceGroups.define(newRgName) .withRegion(Region.US_SOUTH_CENTRAL) .create(); - resourceGroup = resourceGroups.get(rgName); + resourceGroup = resourceGroups.getByName(rgName); } @AfterClass @@ -65,7 +65,7 @@ public void canCreateUpdateMoveResource() throws Exception { // Get Assert.assertNotNull(genericResources.get(rgName, resource.resourceProviderNamespace(), resource.parentResourceId(), resource.resourceType(), resource.name(), resource.apiVersion())); // Move - genericResources.moveResources(rgName, resourceGroups.get(newRgName), Arrays.asList(resource.id())); + genericResources.moveResources(rgName, resourceGroups.getByName(newRgName), Arrays.asList(resource.id())); Assert.assertFalse(genericResources.checkExistence(rgName, resource.resourceProviderNamespace(), resource.parentResourceId(), resource.resourceType(), resource.name(), resource.apiVersion())); resource = genericResources.get(newRgName, resource.resourceProviderNamespace(), resource.parentResourceId(), resource.resourceType(), resource.name(), resource.apiVersion()); Assert.assertNotNull(resource); diff --git a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceGroupsTests.java b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceGroupsTests.java index 82c23bfe8b15..2ecdf25901de 100644 --- a/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceGroupsTests.java +++ b/azure-mgmt-resources/src/test/java/com/microsoft/azure/management/resources/ResourceGroupsTests.java @@ -37,7 +37,7 @@ public void canCreateResourceGroup() throws Exception { Assert.assertEquals("tagvalue", groupResult.tags().get("tagname")); Assert.assertEquals(location, groupResult.region()); // Get - ResourceGroup getGroup = resourceGroups.get(rgName); + ResourceGroup getGroup = resourceGroups.getByName(rgName); Assert.assertNotNull(getGroup); Assert.assertEquals(rgName, getGroup.name()); // Update diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageAvailabilitySet.java b/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageAvailabilitySet.java index 541d5ed61c5f..96d9360ec65b 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageAvailabilitySet.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageAvailabilitySet.java @@ -178,7 +178,7 @@ public static void main(String[] args) { System.out.println(f.getMessage()); f.printStackTrace(); } finally { - if (azure.resourceGroups().get(rgName) != null) { + if (azure.resourceGroups().getByName(rgName) != null) { System.out.println("Deleting Resource Group: " + rgName); azure.resourceGroups().delete(rgName); System.out.println("Deleted Resource Group: " + rgName); diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageVirtualMachine.java b/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageVirtualMachine.java index 38bf65e4a423..b16eb732de4e 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageVirtualMachine.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/compute/samples/ManageVirtualMachine.java @@ -225,7 +225,7 @@ public static void main(String[] args) { System.out.println(f.getMessage()); f.printStackTrace(); } finally { - if (azure.resourceGroups().get(rgName) != null) { + if (azure.resourceGroups().getByName(rgName) != null) { System.out.println("Deleting Resource Group: " + rgName); azure.resourceGroups().delete(rgName); System.out.println("Deleted Resource Group: " + rgName); diff --git a/azure-samples/src/main/java/com/microsoft/azure/management/storage/samples/ManageStorageAccount.java b/azure-samples/src/main/java/com/microsoft/azure/management/storage/samples/ManageStorageAccount.java index 1af5e815a6c6..22643fdae3a0 100644 --- a/azure-samples/src/main/java/com/microsoft/azure/management/storage/samples/ManageStorageAccount.java +++ b/azure-samples/src/main/java/com/microsoft/azure/management/storage/samples/ManageStorageAccount.java @@ -128,7 +128,7 @@ public static void main(String[] args) { System.out.println(f.getMessage()); f.printStackTrace(); } finally { - if (azure.resourceGroups().get(rgName) != null) { + if (azure.resourceGroups().getByName(rgName) != null) { System.out.println("Deleting Resource Group: " + rgName); azure.resourceGroups().delete(rgName); System.out.println("Deleted Resource Group: " + rgName); From 59c8be59799717ad16a24251e6d7b3584ca8e4bf Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 13:55:40 -0700 Subject: [PATCH 03/20] base class for collection classes for shared functionality --- .../implementation/ResourcesImpl.java | 34 +++++++++++++++++++ .../implementation/package-info.java | 8 +++++ 2 files changed, 42 insertions(+) create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java create mode 100644 azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/package-info.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java new file mode 100644 index 000000000000..83d93c5e252f --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; + +import java.io.IOException; + +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; + +/** + * Base class for resource collection classes. + * (Internal use only) + * @param the individual resource type returned + */ +public abstract class ResourcesImpl + implements + SupportsGettingById, + SupportsGettingByGroup { + + @Override + public abstract T getByGroup(String groupName, String name) throws CloudException, IOException; + + @Override + public T getById(String id) throws CloudException, IOException { + return this.getByGroup( + ResourceUtils.groupFromResourceId(id), + ResourceUtils.nameFromResourceId(id)); + } +} diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/package-info.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/package-info.java new file mode 100644 index 000000000000..ab723c700e77 --- /dev/null +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +/** + * This package contains shared implementation classes for resource collections. + */ +package com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation; From e19cafa327e583136627b8ab5d101ff9396d77eb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 13:56:57 -0700 Subject: [PATCH 04/20] adding getById() support to AvailabilitySets --- .../microsoft/azure/management/compute/AvailabilitySets.java | 2 ++ .../compute/implementation/AvailabilitySetsImpl.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java index 40fef38bb143..d4dc0a8dcf32 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -13,6 +14,7 @@ public interface AvailabilitySets extends SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsListing, SupportsCreating, SupportsDeleting, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 2ae75bd89a3d..28c91bbae7af 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetInner; import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetsInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; @@ -26,7 +27,9 @@ /** * The implementation for {@link AvailabilitySets}. */ -class AvailabilitySetsImpl implements AvailabilitySets { +class AvailabilitySetsImpl + extends ResourcesImpl + implements AvailabilitySets { private final AvailabilitySetsInner client; private final ResourceManager resourceManager; private final PagedListConverter converter; From 0b5952e245a3f7fe561e4292993ae074bd1bb2c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 13:57:17 -0700 Subject: [PATCH 05/20] adding getById() support to VirtualMachines --- .../com/microsoft/azure/management/compute/VirtualMachines.java | 2 ++ .../management/compute/implementation/VirtualMachinesImpl.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java index b12fa96e980d..8643d232a4fa 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java @@ -4,6 +4,7 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -18,6 +19,7 @@ public interface VirtualMachines extends SupportsListing, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsCreating, SupportsDeleting, SupportsDeletingByGroup { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index bbbf39f636c9..dd430bfbd3ac 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -22,6 +22,7 @@ import com.microsoft.azure.management.compute.implementation.api.VirtualMachineCaptureResultInner; import com.microsoft.azure.management.network.implementation.NetworkManager; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; @@ -37,6 +38,7 @@ * The implementation for {@link VirtualMachines}. */ class VirtualMachinesImpl + extends ResourcesImpl implements VirtualMachines { private final VirtualMachinesInner client; private final VirtualMachineSizesInner virtualMachineSizesClient; From 2dfb06af2f06ded7090ca2b2308340338424a454 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:03:56 -0700 Subject: [PATCH 06/20] adding getById() support to NICs --- .../azure/management/network/NetworkInterfaces.java | 2 ++ .../network/implementation/NetworkInterfacesImpl.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterfaces.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterfaces.java index 27d4d2cbdf72..b9c613784b08 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterfaces.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkInterfaces.java @@ -2,6 +2,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -15,6 +16,7 @@ public interface NetworkInterfaces extends SupportsListing, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsDeleting, SupportsDeletingByGroup { } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index a1411e6d57d8..cb3686df0e50 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -9,6 +9,7 @@ import com.microsoft.azure.management.network.implementation.api.NetworkInterfaceIPConfiguration; import com.microsoft.azure.management.network.implementation.api.NetworkInterfaceDnsSettings; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -19,7 +20,9 @@ /** * The type representing Azure network interfaces. */ -class NetworkInterfacesImpl implements NetworkInterfaces { +class NetworkInterfacesImpl + extends ResourcesImpl + implements NetworkInterfaces { private final NetworkInterfacesInner client; private final ResourceManager resourceManager; private final NetworkManager networkManager; From 305fe207ce235b64de83c15c0f659d39250e28f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:05:52 -0700 Subject: [PATCH 07/20] adding getById() support to Networks --- .../com/microsoft/azure/management/network/Networks.java | 2 ++ .../management/network/implementation/NetworksImpl.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Networks.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Networks.java index 9e612103d38f..cc817806b046 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Networks.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/Networks.java @@ -7,6 +7,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -21,6 +22,7 @@ public interface Networks extends SupportsListing, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsDeleting, SupportsDeletingByGroup { } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index e63b0310d9ba..52da71f90f52 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -15,6 +15,7 @@ import com.microsoft.azure.management.network.implementation.api.VirtualNetworkInner; import com.microsoft.azure.management.network.implementation.api.VirtualNetworksInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -26,7 +27,9 @@ * Implementation of the Networks interface. * (Internal use only) */ -class NetworksImpl implements Networks { +class NetworksImpl + extends ResourcesImpl + implements Networks { private final VirtualNetworksInner client; private final ResourceManager resourceManager; private final PagedListConverter converter; From d582aafd78bec3a535f7313fe217adafcf4cd19f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:09:37 -0700 Subject: [PATCH 08/20] adding getById() support to network security groups --- .../azure/management/network/NetworkSecurityGroups.java | 2 ++ .../network/implementation/NetworkSecurityGroupsImpl.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroups.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroups.java index 252296768e4c..3ec2133498e4 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroups.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/NetworkSecurityGroups.java @@ -7,6 +7,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -21,6 +22,7 @@ public interface NetworkSecurityGroups extends SupportsListing, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsDeleting, SupportsDeletingByGroup { } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index e078848198a7..e44425f78f0a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.network.implementation.api.NetworkSecurityGroupsInner; import com.microsoft.azure.management.network.implementation.api.SecurityRuleInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -24,7 +25,9 @@ * Implementation of the NetworkSecurityGroups interface. * (Internal use only) */ -class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { +class NetworkSecurityGroupsImpl + extends ResourcesImpl + implements NetworkSecurityGroups { private final NetworkSecurityGroupsInner client; private final ResourceManager resourceManager; private final PagedListConverter converter; From 975115d6b198fc08eb4746928fcfe5f654eb212e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:11:36 -0700 Subject: [PATCH 09/20] adding support for getById() to public IP addresses --- .../microsoft/azure/management/network/PublicIpAddresses.java | 2 ++ .../network/implementation/PublicIpAddressesImpl.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java index 6c13a57f8c75..8711d9f8bf90 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java @@ -7,6 +7,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -22,5 +23,6 @@ public interface PublicIpAddresses extends SupportsDeleting, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsDeletingByGroup { } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 6f4d6e627033..3b5f9a2e12d1 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.network.implementation.api.PublicIPAddressInner; import com.microsoft.azure.management.network.implementation.api.PublicIPAddressesInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -24,6 +25,7 @@ * (Internal use only) */ class PublicIpAddressesImpl + extends ResourcesImpl implements PublicIpAddresses { private final PublicIPAddressesInner client; private final ResourceManager resourceManager; From 282d3806d02cf1b28dc276ee8c588a789aad1bf8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:14:21 -0700 Subject: [PATCH 10/20] adding getById support to Deployments --- .../com/microsoft/azure/management/resources/Deployments.java | 2 ++ .../management/resources/implementation/DeploymentsImpl.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java index b4e6bf66f8c4..b91974475f70 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/Deployments.java @@ -9,6 +9,7 @@ import com.microsoft.azure.CloudException; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByName; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; @@ -26,6 +27,7 @@ public interface Deployments extends SupportsListingByGroup, SupportsGettingByName, SupportsGettingByGroup, + SupportsGettingById, SupportsDeleting, SupportsDeletingByGroup { /** diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index a7c048ba423a..cda9cc4b7e7e 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -10,6 +10,7 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Deployments; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.api.DeploymentOperationsInner; @@ -26,6 +27,7 @@ * The implementation for Deployments and its parent interfaces. */ final class DeploymentsImpl + extends ResourcesImpl implements Deployments { private final DeploymentsInner client; From 2137f270cf963546eed69a6a9b9edce2ab915d99 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:24:17 -0700 Subject: [PATCH 11/20] adding getById() support to storage accounts --- .../com/microsoft/azure/management/storage/StorageAccounts.java | 2 ++ .../management/storage/implementation/StorageAccountsImpl.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java index 9236968c523f..723e5c069da9 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/StorageAccounts.java @@ -9,6 +9,7 @@ import com.microsoft.azure.CloudException; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; @@ -26,6 +27,7 @@ public interface StorageAccounts extends SupportsDeleting, SupportsListingByGroup, SupportsGettingByGroup, + SupportsGettingById, SupportsDeletingByGroup { /** * Checks that account name is valid and is not in use. diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index a67059547f46..8dea45369c7d 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -10,6 +10,7 @@ import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; @@ -29,6 +30,7 @@ * The implementation of StorageAccounts and its parent interfaces. */ class StorageAccountsImpl + extends ResourcesImpl implements StorageAccounts { private final StorageAccountsInner client; private final ResourceManager resourceManager; From 528399620c60c051489eede524153598e92a0ead Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:27:59 -0700 Subject: [PATCH 12/20] making getById final in th ebase class since there is no need to override it yet --- .../fluentcore/arm/collection/implementation/ResourcesImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java index 83d93c5e252f..ce60aad6d275 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java @@ -26,7 +26,7 @@ public abstract class ResourcesImpl public abstract T getByGroup(String groupName, String name) throws CloudException, IOException; @Override - public T getById(String id) throws CloudException, IOException { + public final T getById(String id) throws CloudException, IOException { return this.getByGroup( ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); From 092380ead30daf3ff44fbba298f75cf59116e297 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:34:50 -0700 Subject: [PATCH 13/20] adding getById test to TestTemplate --- azure/src/test/java/com/microsoft/azure/TestTemplate.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/azure/src/test/java/com/microsoft/azure/TestTemplate.java b/azure/src/test/java/com/microsoft/azure/TestTemplate.java index aae728b4c195..217efcac966e 100644 --- a/azure/src/test/java/com/microsoft/azure/TestTemplate.java +++ b/azure/src/test/java/com/microsoft/azure/TestTemplate.java @@ -7,6 +7,7 @@ import com.microsoft.azure.management.resources.ResourceGroups; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; @@ -21,7 +22,7 @@ */ public abstract class TestTemplate< T extends GroupableResource, - C extends SupportsListing & SupportsGettingByGroup & SupportsDeleting> { + C extends SupportsListing & SupportsGettingByGroup & SupportsDeleting & SupportsGettingById> { protected String testId = String.valueOf(System.currentTimeMillis() % 100000L); private T resource; @@ -61,7 +62,10 @@ public int verifyListing() throws CloudException, IOException { * @throws IOException if anything goes wrong */ public T verifyGetting() throws CloudException, IOException { - return this.collection.getByGroup(this.resource.resourceGroupName(), this.resource.name()); + T resourceByGroup = this.collection.getByGroup(this.resource.resourceGroupName(), this.resource.name()); + T resourceById = this.collection.getById(resourceByGroup.id()); + Assert.assertTrue(resourceById.id().equalsIgnoreCase(resourceByGroup.id())); + return resourceById; } /** From d9d76ca6f88674ff6847b8bdbd73e626e3e89fea Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 14:48:59 -0700 Subject: [PATCH 14/20] enforcing the presence of a consistent createFluentModel(name) across collections via abstract method on ResourcesImpl --- .../compute/implementation/AvailabilitySetsImpl.java | 5 +++-- .../compute/implementation/VirtualMachinesImpl.java | 5 +++-- .../network/implementation/NetworkInterfacesImpl.java | 5 +++-- .../network/implementation/NetworkSecurityGroupsImpl.java | 6 ++++-- .../management/network/implementation/NetworksImpl.java | 5 +++-- .../network/implementation/PublicIpAddressesImpl.java | 5 +++-- .../arm/collection/implementation/ResourcesImpl.java | 5 ++++- .../resources/implementation/DeploymentsImpl.java | 5 +++-- .../storage/implementation/StorageAccountsImpl.java | 8 ++++---- 9 files changed, 30 insertions(+), 19 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 28c91bbae7af..7c0bf1c2e923 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -28,7 +28,7 @@ * The implementation for {@link AvailabilitySets}. */ class AvailabilitySetsImpl - extends ResourcesImpl + extends ResourcesImpl implements AvailabilitySets { private final AvailabilitySetsInner client; private final ResourceManager resourceManager; @@ -102,7 +102,8 @@ public void delete(String groupName, String name) throws Exception { * Fluent model helpers. **************************************************************/ - private AvailabilitySetImpl createFluentModel(String name) { + @Override + protected AvailabilitySetImpl createFluentModel(String name) { AvailabilitySetInner availabilitySetInner = new AvailabilitySetInner(); return new AvailabilitySetImpl(name, availabilitySetInner, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index 023d5986d064..a7354669e4fa 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -39,7 +39,7 @@ * The implementation for {@link VirtualMachines}. */ class VirtualMachinesImpl - extends ResourcesImpl + extends ResourcesImpl implements VirtualMachines { private final VirtualMachinesInner client; private final VirtualMachineSizesInner virtualMachineSizesClient; @@ -177,7 +177,8 @@ public String capture(String groupName, String name, // Helper methods // - private VirtualMachineImpl createFluentModel(String name) { + @Override + protected VirtualMachineImpl createFluentModel(String name) { VirtualMachineInner inner = new VirtualMachineInner(); inner.withStorageProfile(new StorageProfile() .withOsDisk(new OSDisk()) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index cb3686df0e50..9b5f50fdf895 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -21,7 +21,7 @@ * The type representing Azure network interfaces. */ class NetworkInterfacesImpl - extends ResourcesImpl + extends ResourcesImpl implements NetworkInterfaces { private final NetworkInterfacesInner client; private final ResourceManager resourceManager; @@ -77,7 +77,8 @@ public NetworkInterface.DefinitionBlank define(String name) { return createFluentModel(name); } - private NetworkInterfaceImpl createFluentModel(String name) { + @Override + protected NetworkInterfaceImpl createFluentModel(String name) { NetworkInterfaceInner inner = new NetworkInterfaceInner(); inner.withIpConfigurations(new ArrayList()); inner.withDnsSettings(new NetworkInterfaceDnsSettings()); diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index e44425f78f0a..063e09dd60e9 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -26,7 +26,7 @@ * (Internal use only) */ class NetworkSecurityGroupsImpl - extends ResourcesImpl + extends ResourcesImpl implements NetworkSecurityGroups { private final NetworkSecurityGroupsInner client; private final ResourceManager resourceManager; @@ -77,7 +77,9 @@ public NetworkSecurityGroupImpl define(String name) { } // Fluent model create helpers - private NetworkSecurityGroupImpl createFluentModel(String name) { + + @Override + protected NetworkSecurityGroupImpl createFluentModel(String name) { NetworkSecurityGroupInner inner = new NetworkSecurityGroupInner(); // Initialize rules diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index 52da71f90f52..b3efc7b71c99 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -28,7 +28,7 @@ * (Internal use only) */ class NetworksImpl - extends ResourcesImpl + extends ResourcesImpl implements Networks { private final VirtualNetworksInner client; private final ResourceManager resourceManager; @@ -80,7 +80,8 @@ public NetworkImpl define(String name) { // Fluent model create helpers - private NetworkImpl createFluentModel(String name) { + @Override + protected NetworkImpl createFluentModel(String name) { VirtualNetworkInner inner = new VirtualNetworkInner(); // Initialize address space diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 3b5f9a2e12d1..219cf6f66924 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -25,7 +25,7 @@ * (Internal use only) */ class PublicIpAddressesImpl - extends ResourcesImpl + extends ResourcesImpl implements PublicIpAddresses { private final PublicIPAddressesInner client; private final ResourceManager resourceManager; @@ -77,7 +77,8 @@ public PublicIpAddressImpl define(String name) { // Fluent model create helpers - private PublicIpAddressImpl createFluentModel(String name) { + @Override + protected PublicIpAddressImpl createFluentModel(String name) { PublicIPAddressInner inner = new PublicIPAddressInner(); if (null == inner.dnsSettings()) { diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java index ce60aad6d275..4d599dea14dc 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java @@ -16,8 +16,9 @@ * Base class for resource collection classes. * (Internal use only) * @param the individual resource type returned + * @param the individual resource implementation */ -public abstract class ResourcesImpl +public abstract class ResourcesImpl implements SupportsGettingById, SupportsGettingByGroup { @@ -31,4 +32,6 @@ public final T getById(String id) throws CloudException, IOException { ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } + + protected abstract ImplT createFluentModel(String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index cda9cc4b7e7e..520839b0656f 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -27,7 +27,7 @@ * The implementation for Deployments and its parent interfaces. */ final class DeploymentsImpl - extends ResourcesImpl + extends ResourcesImpl implements Deployments { private final DeploymentsInner client; @@ -105,7 +105,8 @@ public boolean checkExistence(String resourceGroupName, String deploymentName) t return client.checkExistence(resourceGroupName, deploymentName).getBody(); } - private DeploymentImpl createFluentModel(String name) { + @Override + protected DeploymentImpl createFluentModel(String name) { DeploymentExtendedInner deploymentExtendedInner = new DeploymentExtendedInner(); deploymentExtendedInner.withName(name); return new DeploymentImpl(deploymentExtendedInner, client, deploymentOperationsClient, this.resourceManager); diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index 8dea45369c7d..78c1485ad5fa 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -30,7 +30,7 @@ * The implementation of StorageAccounts and its parent interfaces. */ class StorageAccountsImpl - extends ResourcesImpl + extends ResourcesImpl implements StorageAccounts { private final StorageAccountsInner client; private final ResourceManager resourceManager; @@ -100,9 +100,9 @@ public Page nextPage(String nextPageLink) throws RestExcept }; } - private StorageAccountImpl createFluentModel(String name) { - StorageAccountInner storageAccountInner = new StorageAccountInner(); - return new StorageAccountImpl(name, storageAccountInner, this.client, this.resourceManager); + @Override + protected StorageAccountImpl createFluentModel(String name) { + return new StorageAccountImpl(name, new StorageAccountInner(), this.client, this.resourceManager); } private StorageAccountImpl createFluentModel(StorageAccountInner storageAccountInner) { From 78c0210af8522762ea0aab1016ad7ddbb3752735 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 15:33:30 -0700 Subject: [PATCH 15/20] renaming ResourcesImpl as GroupableResourcesImpl; adding a requirement for the other createFluentWrapper via an abstract method on the base class --- .../compute/implementation/AvailabilitySetsImpl.java | 10 +++++----- .../compute/implementation/VirtualMachinesImpl.java | 7 ++++--- .../implementation/NetworkInterfacesImpl.java | 7 ++++--- .../implementation/NetworkSecurityGroupsImpl.java | 7 ++++--- .../network/implementation/NetworksImpl.java | 7 ++++--- .../implementation/PublicIpAddressesImpl.java | 7 ++++--- ...esourcesImpl.java => GroupableResourcesImpl.java} | 10 +++++++++- .../resources/implementation/DeploymentImpl.java | 1 - .../resources/implementation/DeploymentsImpl.java | 12 ++++++++---- .../storage/implementation/StorageAccountsImpl.java | 7 ++++--- 10 files changed, 46 insertions(+), 29 deletions(-) rename azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/{ResourcesImpl.java => GroupableResourcesImpl.java} (77%) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 7c0bf1c2e923..22f696a6bcc3 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -13,7 +13,7 @@ import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetInner; import com.microsoft.azure.management.compute.implementation.api.AvailabilitySetsInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; @@ -28,7 +28,7 @@ * The implementation for {@link AvailabilitySets}. */ class AvailabilitySetsImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements AvailabilitySets { private final AvailabilitySetsInner client; private final ResourceManager resourceManager; @@ -104,14 +104,14 @@ public void delete(String groupName, String name) throws Exception { @Override protected AvailabilitySetImpl createFluentModel(String name) { - AvailabilitySetInner availabilitySetInner = new AvailabilitySetInner(); return new AvailabilitySetImpl(name, - availabilitySetInner, + new AvailabilitySetInner(), this.client, this.resourceManager); } - private AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilitySetInner) { + @Override + protected AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilitySetInner) { return new AvailabilitySetImpl(availabilitySetInner.name(), availabilitySetInner, this.client, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index a7354669e4fa..ed88e495301b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -23,7 +23,7 @@ import com.microsoft.azure.management.network.implementation.NetworkManager; import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; @@ -39,7 +39,7 @@ * The implementation for {@link VirtualMachines}. */ class VirtualMachinesImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements VirtualMachines { private final VirtualMachinesInner client; private final VirtualMachineSizesInner virtualMachineSizesClient; @@ -196,7 +196,8 @@ protected VirtualMachineImpl createFluentModel(String name) { this.networkManager); } - private VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachineInner) { + @Override + protected VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachineInner) { return new VirtualMachineImpl(virtualMachineInner.name(), virtualMachineInner, this.client, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index 9b5f50fdf895..ef3abf51dfa2 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -9,7 +9,7 @@ import com.microsoft.azure.management.network.implementation.api.NetworkInterfaceIPConfiguration; import com.microsoft.azure.management.network.implementation.api.NetworkInterfaceDnsSettings; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -21,7 +21,7 @@ * The type representing Azure network interfaces. */ class NetworkInterfacesImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements NetworkInterfaces { private final NetworkInterfacesInner client; private final ResourceManager resourceManager; @@ -89,7 +89,8 @@ protected NetworkInterfaceImpl createFluentModel(String name) { this.resourceManager); } - private NetworkInterfaceImpl createFluentModel(NetworkInterfaceInner inner) { + @Override + protected NetworkInterfaceImpl createFluentModel(NetworkInterfaceInner inner) { return new NetworkInterfaceImpl(inner.name(), inner, this.client, diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index 063e09dd60e9..1e4f63f28d34 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -13,7 +13,7 @@ import com.microsoft.azure.management.network.implementation.api.NetworkSecurityGroupsInner; import com.microsoft.azure.management.network.implementation.api.SecurityRuleInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -26,7 +26,7 @@ * (Internal use only) */ class NetworkSecurityGroupsImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements NetworkSecurityGroups { private final NetworkSecurityGroupsInner client; private final ResourceManager resourceManager; @@ -94,7 +94,8 @@ protected NetworkSecurityGroupImpl createFluentModel(String name) { return new NetworkSecurityGroupImpl(name, inner, this.client, this.resourceManager); } - private NetworkSecurityGroupImpl createFluentModel(NetworkSecurityGroupInner inner) { + @Override + protected NetworkSecurityGroupImpl createFluentModel(NetworkSecurityGroupInner inner) { return new NetworkSecurityGroupImpl(inner.name(), inner, this.client, this.resourceManager); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index b3efc7b71c99..b40cbd151290 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -15,7 +15,7 @@ import com.microsoft.azure.management.network.implementation.api.VirtualNetworkInner; import com.microsoft.azure.management.network.implementation.api.VirtualNetworksInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -28,7 +28,7 @@ * (Internal use only) */ class NetworksImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements Networks { private final VirtualNetworksInner client; private final ResourceManager resourceManager; @@ -114,7 +114,8 @@ protected NetworkImpl createFluentModel(String name) { return new NetworkImpl(name, inner, this.client, this.resourceManager); } - private NetworkImpl createFluentModel(VirtualNetworkInner inner) { + @Override + protected NetworkImpl createFluentModel(VirtualNetworkInner inner) { return new NetworkImpl(inner.name(), inner, this.client, this.resourceManager); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 219cf6f66924..29a5871e40cb 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -13,7 +13,7 @@ import com.microsoft.azure.management.network.implementation.api.PublicIPAddressInner; import com.microsoft.azure.management.network.implementation.api.PublicIPAddressesInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -25,7 +25,7 @@ * (Internal use only) */ class PublicIpAddressesImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements PublicIpAddresses { private final PublicIPAddressesInner client; private final ResourceManager resourceManager; @@ -88,7 +88,8 @@ protected PublicIpAddressImpl createFluentModel(String name) { return new PublicIpAddressImpl(name, inner, this.client, this.resourceManager); } - private PublicIpAddressImpl createFluentModel(PublicIPAddressInner inner) { + @Override + protected PublicIpAddressImpl createFluentModel(PublicIPAddressInner inner) { return new PublicIpAddressImpl(inner.id(), inner, this.client, this.resourceManager); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java similarity index 77% rename from azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java rename to azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index 4d599dea14dc..e656882b0d84 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/ResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -8,17 +8,23 @@ import java.io.IOException; import com.microsoft.azure.CloudException; +import com.microsoft.azure.Resource; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; /** * Base class for resource collection classes. * (Internal use only) * @param the individual resource type returned * @param the individual resource implementation + * @param the wrapper inner type */ -public abstract class ResourcesImpl +public abstract class GroupableResourcesImpl< + T extends GroupableResource, + ImplT extends T, + InnerT extends Resource> implements SupportsGettingById, SupportsGettingByGroup { @@ -34,4 +40,6 @@ public final T getById(String id) throws CloudException, IOException { } protected abstract ImplT createFluentModel(String name); + + protected abstract ImplT createFluentModel(InnerT inner); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java index 6295de79b2a2..4d48f6cbd745 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentImpl.java @@ -71,7 +71,6 @@ final class DeploymentImpl extends this.objectMapper = new ObjectMapper(); } - @Override public String resourceGroupName() { return this.resourceGroupName; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java index 520839b0656f..cdc810a59923 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/DeploymentsImpl.java @@ -10,7 +10,6 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.Deployments; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.api.DeploymentOperationsInner; @@ -27,7 +26,6 @@ * The implementation for Deployments and its parent interfaces. */ final class DeploymentsImpl - extends ResourcesImpl implements Deployments { private final DeploymentsInner client; @@ -105,14 +103,20 @@ public boolean checkExistence(String resourceGroupName, String deploymentName) t return client.checkExistence(resourceGroupName, deploymentName).getBody(); } - @Override protected DeploymentImpl createFluentModel(String name) { DeploymentExtendedInner deploymentExtendedInner = new DeploymentExtendedInner(); deploymentExtendedInner.withName(name); return new DeploymentImpl(deploymentExtendedInner, client, deploymentOperationsClient, this.resourceManager); } - private DeploymentImpl createFluentModel(DeploymentExtendedInner deploymentExtendedInner) { + protected DeploymentImpl createFluentModel(DeploymentExtendedInner deploymentExtendedInner) { return new DeploymentImpl(deploymentExtendedInner, client, deploymentOperationsClient, this.resourceManager); } + + @Override + public Deployment getById(String id) throws CloudException, IllegalArgumentException, IOException { + return this.getByGroup( + ResourceUtils.groupFromResourceId(id), + ResourceUtils.nameFromResourceId(id)); + } } diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index 78c1485ad5fa..fea0544cd99f 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -10,7 +10,7 @@ import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ResourcesImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; @@ -30,7 +30,7 @@ * The implementation of StorageAccounts and its parent interfaces. */ class StorageAccountsImpl - extends ResourcesImpl + extends GroupableResourcesImpl implements StorageAccounts { private final StorageAccountsInner client; private final ResourceManager resourceManager; @@ -105,7 +105,8 @@ protected StorageAccountImpl createFluentModel(String name) { return new StorageAccountImpl(name, new StorageAccountInner(), this.client, this.resourceManager); } - private StorageAccountImpl createFluentModel(StorageAccountInner storageAccountInner) { + @Override + protected StorageAccountImpl createFluentModel(StorageAccountInner storageAccountInner) { return new StorageAccountImpl(storageAccountInner.name(), storageAccountInner, this.client, this.resourceManager); } } From b7c2afc0d46992de4035d643c051ec91b076e004 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 15:48:36 -0700 Subject: [PATCH 16/20] factoring ResourceManager reference logic out of concrete collection impls and into the common base class --- .../compute/implementation/AvailabilitySetsImpl.java | 9 ++++----- .../compute/implementation/VirtualMachinesImpl.java | 7 +++---- .../network/implementation/NetworkInterfacesImpl.java | 7 +++---- .../implementation/NetworkSecurityGroupsImpl.java | 7 +++---- .../network/implementation/NetworksImpl.java | 7 +++---- .../network/implementation/PublicIpAddressesImpl.java | 7 +++---- .../implementation/GroupableResourcesImpl.java | 11 +++++++++++ .../storage/implementation/StorageAccountsImpl.java | 7 +++---- 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 22f696a6bcc3..34a7512f6e92 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -31,13 +31,12 @@ class AvailabilitySetsImpl extends GroupableResourcesImpl implements AvailabilitySets { private final AvailabilitySetsInner client; - private final ResourceManager resourceManager; private final PagedListConverter converter; AvailabilitySetsImpl( final AvailabilitySetsInner client, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public AvailabilitySet typeConvert(AvailabilitySetInner inner) { @@ -48,7 +47,7 @@ public AvailabilitySet typeConvert(AvailabilitySetInner inner) { @Override public PagedList list() throws CloudException, IOException { - return new GroupPagedList(this.resourceManager.resourceGroups().list()) { + return new GroupPagedList(this.resourceManager().resourceGroups().list()) { @Override public List listNextGroup(String resourceGroupName) throws RestException, IOException { PageImpl page = new PageImpl<>(); @@ -107,7 +106,7 @@ protected AvailabilitySetImpl createFluentModel(String name) { return new AvailabilitySetImpl(name, new AvailabilitySetInner(), this.client, - this.resourceManager); + this.resourceManager()); } @Override @@ -115,6 +114,6 @@ protected AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilit return new AvailabilitySetImpl(availabilitySetInner.name(), availabilitySetInner, this.client, - this.resourceManager); + this.resourceManager()); } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index ed88e495301b..a0d3700f52da 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -44,7 +44,6 @@ class VirtualMachinesImpl private final VirtualMachinesInner client; private final VirtualMachineSizesInner virtualMachineSizesClient; private final ComputeManager computeManager; - private final ResourceManager resourceManager; private final StorageManager storageManager; private final NetworkManager networkManager; private final PagedListConverter converter; @@ -55,10 +54,10 @@ class VirtualMachinesImpl ResourceManager resourceManager, StorageManager storageManager, NetworkManager networkManager) { + super(resourceManager); this.client = client; this.virtualMachineSizesClient = virtualMachineSizesClient; this.computeManager = computeManager; - this.resourceManager = resourceManager; this.storageManager = storageManager; this.networkManager = networkManager; this.converter = new PagedListConverter() { @@ -191,7 +190,7 @@ protected VirtualMachineImpl createFluentModel(String name) { inner, this.client, this.computeManager, - this.resourceManager, + this.resourceManager(), this.storageManager, this.networkManager); } @@ -202,7 +201,7 @@ protected VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachin virtualMachineInner, this.client, this.computeManager, - this.resourceManager, + this.resourceManager(), this.storageManager, this.networkManager); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index ef3abf51dfa2..d702285caa29 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -24,7 +24,6 @@ class NetworkInterfacesImpl extends GroupableResourcesImpl implements NetworkInterfaces { private final NetworkInterfacesInner client; - private final ResourceManager resourceManager; private final NetworkManager networkManager; private final PagedListConverter converter; @@ -33,9 +32,9 @@ class NetworkInterfacesImpl final NetworkInterfacesInner client, final NetworkManager networkManager, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; this.networkManager = networkManager; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public NetworkInterface typeConvert(NetworkInterfaceInner inner) { @@ -86,7 +85,7 @@ protected NetworkInterfaceImpl createFluentModel(String name) { inner, this.client, this.networkManager, - this.resourceManager); + this.resourceManager()); } @Override @@ -95,6 +94,6 @@ protected NetworkInterfaceImpl createFluentModel(NetworkInterfaceInner inner) { inner, this.client, this.networkManager, - this.resourceManager); + this.resourceManager()); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index 1e4f63f28d34..08991c853efc 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -29,12 +29,11 @@ class NetworkSecurityGroupsImpl extends GroupableResourcesImpl implements NetworkSecurityGroups { private final NetworkSecurityGroupsInner client; - private final ResourceManager resourceManager; private final PagedListConverter converter; NetworkSecurityGroupsImpl(final NetworkSecurityGroupsInner client, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public NetworkSecurityGroup typeConvert(NetworkSecurityGroupInner inner) { @@ -91,11 +90,11 @@ protected NetworkSecurityGroupImpl createFluentModel(String name) { inner.withDefaultSecurityRules(new ArrayList()); } - return new NetworkSecurityGroupImpl(name, inner, this.client, this.resourceManager); + return new NetworkSecurityGroupImpl(name, inner, this.client, this.resourceManager()); } @Override protected NetworkSecurityGroupImpl createFluentModel(NetworkSecurityGroupInner inner) { - return new NetworkSecurityGroupImpl(inner.name(), inner, this.client, this.resourceManager); + return new NetworkSecurityGroupImpl(inner.name(), inner, this.client, this.resourceManager()); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index b40cbd151290..52a79d71c626 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -31,12 +31,11 @@ class NetworksImpl extends GroupableResourcesImpl implements Networks { private final VirtualNetworksInner client; - private final ResourceManager resourceManager; private final PagedListConverter converter; NetworksImpl(final VirtualNetworksInner client, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public Network typeConvert(VirtualNetworkInner inner) { @@ -111,11 +110,11 @@ protected NetworkImpl createFluentModel(String name) { dhcp.withDnsServers(new ArrayList()); } - return new NetworkImpl(name, inner, this.client, this.resourceManager); + return new NetworkImpl(name, inner, this.client, this.resourceManager()); } @Override protected NetworkImpl createFluentModel(VirtualNetworkInner inner) { - return new NetworkImpl(inner.name(), inner, this.client, this.resourceManager); + return new NetworkImpl(inner.name(), inner, this.client, this.resourceManager()); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 29a5871e40cb..9b35d302171c 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -28,12 +28,11 @@ class PublicIpAddressesImpl extends GroupableResourcesImpl implements PublicIpAddresses { private final PublicIPAddressesInner client; - private final ResourceManager resourceManager; private final PagedListConverter converter; PublicIpAddressesImpl(final PublicIPAddressesInner client, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public PublicIpAddress typeConvert(PublicIPAddressInner inner) { @@ -85,11 +84,11 @@ protected PublicIpAddressImpl createFluentModel(String name) { inner.withDnsSettings(new PublicIPAddressDnsSettings()); } - return new PublicIpAddressImpl(name, inner, this.client, this.resourceManager); + return new PublicIpAddressImpl(name, inner, this.client, this.resourceManager()); } @Override protected PublicIpAddressImpl createFluentModel(PublicIPAddressInner inner) { - return new PublicIpAddressImpl(inner.id(), inner, this.client, this.resourceManager); + return new PublicIpAddressImpl(inner.id(), inner, this.client, this.resourceManager()); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index e656882b0d84..e141bba90c3b 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.implementation.ResourceManager; /** * Base class for resource collection classes. @@ -29,6 +30,16 @@ public abstract class GroupableResourcesImpl< SupportsGettingById, SupportsGettingByGroup { + private final ResourceManager resourceManager; + + protected GroupableResourcesImpl(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + } + + protected ResourceManager resourceManager() { + return this.resourceManager; + } + @Override public abstract T getByGroup(String groupName, String name) throws CloudException, IOException; diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index fea0544cd99f..ec23799ffb3b 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -33,12 +33,11 @@ class StorageAccountsImpl extends GroupableResourcesImpl implements StorageAccounts { private final StorageAccountsInner client; - private final ResourceManager resourceManager; private final PagedListConverter converter; StorageAccountsImpl(final StorageAccountsInner client, final ResourceManager resourceManager) { + super(resourceManager); this.client = client; - this.resourceManager = resourceManager; this.converter = new PagedListConverter() { @Override public StorageAccount typeConvert(StorageAccountInner storageAccountInner) { @@ -102,11 +101,11 @@ public Page nextPage(String nextPageLink) throws RestExcept @Override protected StorageAccountImpl createFluentModel(String name) { - return new StorageAccountImpl(name, new StorageAccountInner(), this.client, this.resourceManager); + return new StorageAccountImpl(name, new StorageAccountInner(), this.client, this.resourceManager()); } @Override protected StorageAccountImpl createFluentModel(StorageAccountInner storageAccountInner) { - return new StorageAccountImpl(storageAccountInner.name(), storageAccountInner, this.client, this.resourceManager); + return new StorageAccountImpl(storageAccountInner.name(), storageAccountInner, this.client, this.resourceManager()); } } From 546c7ddad81352f6fee057b59548eef80862e50c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 16:06:32 -0700 Subject: [PATCH 17/20] factoring client (inner collection) out of concrete collection impls and into the base class --- .../implementation/AvailabilitySetsImpl.java | 24 ++++++------- .../implementation/VirtualMachinesImpl.java | 36 +++++++++---------- .../implementation/NetworkInterfacesImpl.java | 22 ++++++------ .../NetworkSecurityGroupsImpl.java | 18 +++++----- .../network/implementation/NetworksImpl.java | 18 +++++----- .../implementation/PublicIpAddressesImpl.java | 18 +++++----- .../GroupableResourcesImpl.java | 15 ++++---- .../implementation/StorageAccountsImpl.java | 20 +++++------ 8 files changed, 79 insertions(+), 92 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index 34a7512f6e92..a125fa1d8fa0 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -28,15 +28,13 @@ * The implementation for {@link AvailabilitySets}. */ class AvailabilitySetsImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements AvailabilitySets { - private final AvailabilitySetsInner client; private final PagedListConverter converter; AvailabilitySetsImpl( final AvailabilitySetsInner client, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.converter = new PagedListConverter() { @Override public AvailabilitySet typeConvert(AvailabilitySetInner inner) { @@ -47,11 +45,11 @@ public AvailabilitySet typeConvert(AvailabilitySetInner inner) { @Override public PagedList list() throws CloudException, IOException { - return new GroupPagedList(this.resourceManager().resourceGroups().list()) { + return new GroupPagedList(this.resourceManager.resourceGroups().list()) { @Override public List listNextGroup(String resourceGroupName) throws RestException, IOException { PageImpl page = new PageImpl<>(); - page.setItems(client.list(resourceGroupName).getBody()); + page.setItems(innerCollection.list(resourceGroupName).getBody()); page.setNextPageLink(null); return converter.convert(new PagedList(page) { @Override @@ -66,7 +64,7 @@ public Page nextPage(String nextPageLink) throws RestExcep @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { PageImpl page = new PageImpl<>(); - page.setItems(client.list(groupName).getBody()); + page.setItems(this.innerCollection.list(groupName).getBody()); page.setNextPageLink(null); return this.converter.convert(new PagedList(page) { @Override @@ -78,7 +76,7 @@ public Page nextPage(String nextPageLink) throws RestExcep @Override public AvailabilitySetImpl getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse response = this.client.get(groupName, name); + ServiceResponse response = this.innerCollection.get(groupName, name); return createFluentModel(response.getBody()); } @@ -94,7 +92,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } /************************************************************** @@ -105,15 +103,15 @@ public void delete(String groupName, String name) throws Exception { protected AvailabilitySetImpl createFluentModel(String name) { return new AvailabilitySetImpl(name, new AvailabilitySetInner(), - this.client, - this.resourceManager()); + this.innerCollection, + this.resourceManager); } @Override protected AvailabilitySetImpl createFluentModel(AvailabilitySetInner availabilitySetInner) { return new AvailabilitySetImpl(availabilitySetInner.name(), availabilitySetInner, - this.client, - this.resourceManager()); + this.innerCollection, + this.resourceManager); } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index a0d3700f52da..370b7a99ad92 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -39,9 +39,8 @@ * The implementation for {@link VirtualMachines}. */ class VirtualMachinesImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements VirtualMachines { - private final VirtualMachinesInner client; private final VirtualMachineSizesInner virtualMachineSizesClient; private final ComputeManager computeManager; private final StorageManager storageManager; @@ -54,8 +53,7 @@ class VirtualMachinesImpl ResourceManager resourceManager, StorageManager storageManager, NetworkManager networkManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.virtualMachineSizesClient = virtualMachineSizesClient; this.computeManager = computeManager; this.storageManager = storageManager; @@ -73,19 +71,19 @@ public VirtualMachine typeConvert(VirtualMachineInner inner) { @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.listAll(); + ServiceResponse> response = this.innerCollection.listAll(); return converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.list(groupName); + ServiceResponse> response = this.innerCollection.list(groupName); return converter.convert(toPagedList(response.getBody())); } @Override public VirtualMachine getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse response = this.client.get(groupName, name); + ServiceResponse response = this.innerCollection.get(groupName, name); return createFluentModel(response.getBody()); } @@ -96,7 +94,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -132,32 +130,32 @@ public PagedList availableSizesByRegion(Region region) throw @Override public void deallocate(String groupName, String name) throws CloudException, IOException, InterruptedException { - this.client.deallocate(groupName, name); + this.innerCollection.deallocate(groupName, name); } @Override public void generalize(String groupName, String name) throws CloudException, IOException { - this.client.generalize(groupName, name); + this.innerCollection.generalize(groupName, name); } @Override public void powerOff(String groupName, String name) throws CloudException, IOException, InterruptedException { - this.client.powerOff(groupName, name); + this.innerCollection.powerOff(groupName, name); } @Override public void restart(String groupName, String name) throws CloudException, IOException, InterruptedException { - this.client.restart(groupName, name); + this.innerCollection.restart(groupName, name); } @Override public void start(String groupName, String name) throws CloudException, IOException, InterruptedException { - this.client.start(groupName, name); + this.innerCollection.start(groupName, name); } @Override public void redeploy(String groupName, String name) throws CloudException, IOException, InterruptedException { - this.client.redeploy(groupName, name); + this.innerCollection.redeploy(groupName, name); } @Override @@ -167,7 +165,7 @@ public String capture(String groupName, String name, VirtualMachineCaptureParametersInner parameters = new VirtualMachineCaptureParametersInner(); parameters.withDestinationContainerName(containerName); parameters.withOverwriteVhds(overwriteVhd); - ServiceResponse captureResult = this.client.capture(groupName, name, parameters); + ServiceResponse captureResult = this.innerCollection.capture(groupName, name, parameters); ObjectMapper mapper = new ObjectMapper(); //Object to JSON string return mapper.writeValueAsString(captureResult.getBody().output()); @@ -188,9 +186,9 @@ protected VirtualMachineImpl createFluentModel(String name) { .withNetworkInterfaces(new ArrayList())); return new VirtualMachineImpl(name, inner, - this.client, + this.innerCollection, this.computeManager, - this.resourceManager(), + this.resourceManager, this.storageManager, this.networkManager); } @@ -199,9 +197,9 @@ protected VirtualMachineImpl createFluentModel(String name) { protected VirtualMachineImpl createFluentModel(VirtualMachineInner virtualMachineInner) { return new VirtualMachineImpl(virtualMachineInner.name(), virtualMachineInner, - this.client, + this.innerCollection, this.computeManager, - this.resourceManager(), + this.resourceManager, this.storageManager, this.networkManager); } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index d702285caa29..5db63ad7d3a7 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -21,9 +21,8 @@ * The type representing Azure network interfaces. */ class NetworkInterfacesImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements NetworkInterfaces { - private final NetworkInterfacesInner client; private final NetworkManager networkManager; private final PagedListConverter converter; @@ -32,8 +31,7 @@ class NetworkInterfacesImpl final NetworkInterfacesInner client, final NetworkManager networkManager, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.networkManager = networkManager; this.converter = new PagedListConverter() { @Override @@ -45,19 +43,19 @@ public NetworkInterface typeConvert(NetworkInterfaceInner inner) { @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.listAll(); + ServiceResponse> response = innerCollection.listAll(); return converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.list(groupName); + ServiceResponse> response = innerCollection.list(groupName); return converter.convert(response.getBody()); } @Override public NetworkInterface getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse serviceResponse = this.client.get(groupName, name); + ServiceResponse serviceResponse = this.innerCollection.get(groupName, name); return createFluentModel(serviceResponse.getBody()); } @@ -68,7 +66,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -83,17 +81,17 @@ protected NetworkInterfaceImpl createFluentModel(String name) { inner.withDnsSettings(new NetworkInterfaceDnsSettings()); return new NetworkInterfaceImpl(name, inner, - this.client, + this.innerCollection, this.networkManager, - this.resourceManager()); + this.resourceManager); } @Override protected NetworkInterfaceImpl createFluentModel(NetworkInterfaceInner inner) { return new NetworkInterfaceImpl(inner.name(), inner, - this.client, + this.innerCollection, this.networkManager, - this.resourceManager()); + this.resourceManager); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index 08991c853efc..e71a9d2f959e 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -26,14 +26,12 @@ * (Internal use only) */ class NetworkSecurityGroupsImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements NetworkSecurityGroups { - private final NetworkSecurityGroupsInner client; private final PagedListConverter converter; NetworkSecurityGroupsImpl(final NetworkSecurityGroupsInner client, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.converter = new PagedListConverter() { @Override public NetworkSecurityGroup typeConvert(NetworkSecurityGroupInner inner) { @@ -44,19 +42,19 @@ public NetworkSecurityGroup typeConvert(NetworkSecurityGroupInner inner) { @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.listAll(); + ServiceResponse> response = this.innerCollection.listAll(); return converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.list(groupName); + ServiceResponse> response = this.innerCollection.list(groupName); return converter.convert(response.getBody()); } @Override public NetworkSecurityGroupImpl getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse serviceResponse = this.client.get(groupName, name); + ServiceResponse serviceResponse = this.innerCollection.get(groupName, name); return createFluentModel(serviceResponse.getBody()); } @@ -67,7 +65,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -90,11 +88,11 @@ protected NetworkSecurityGroupImpl createFluentModel(String name) { inner.withDefaultSecurityRules(new ArrayList()); } - return new NetworkSecurityGroupImpl(name, inner, this.client, this.resourceManager()); + return new NetworkSecurityGroupImpl(name, inner, this.innerCollection, this.resourceManager); } @Override protected NetworkSecurityGroupImpl createFluentModel(NetworkSecurityGroupInner inner) { - return new NetworkSecurityGroupImpl(inner.name(), inner, this.client, this.resourceManager()); + return new NetworkSecurityGroupImpl(inner.name(), inner, this.innerCollection, this.resourceManager); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index 52a79d71c626..b916ce3d1595 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -28,14 +28,12 @@ * (Internal use only) */ class NetworksImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements Networks { - private final VirtualNetworksInner client; private final PagedListConverter converter; NetworksImpl(final VirtualNetworksInner client, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.converter = new PagedListConverter() { @Override public Network typeConvert(VirtualNetworkInner inner) { @@ -46,19 +44,19 @@ public Network typeConvert(VirtualNetworkInner inner) { @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.listAll(); + ServiceResponse> response = this.innerCollection.listAll(); return converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.list(groupName); + ServiceResponse> response = this.innerCollection.list(groupName); return converter.convert(response.getBody()); } @Override public NetworkImpl getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse serviceResponse = this.client.get(groupName, name); + ServiceResponse serviceResponse = this.innerCollection.get(groupName, name); return createFluentModel(serviceResponse.getBody()); } @@ -69,7 +67,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -110,11 +108,11 @@ protected NetworkImpl createFluentModel(String name) { dhcp.withDnsServers(new ArrayList()); } - return new NetworkImpl(name, inner, this.client, this.resourceManager()); + return new NetworkImpl(name, inner, this.innerCollection, this.resourceManager); } @Override protected NetworkImpl createFluentModel(VirtualNetworkInner inner) { - return new NetworkImpl(inner.name(), inner, this.client, this.resourceManager()); + return new NetworkImpl(inner.name(), inner, this.innerCollection, this.resourceManager); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index 9b35d302171c..feccb56d6a17 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -25,14 +25,12 @@ * (Internal use only) */ class PublicIpAddressesImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements PublicIpAddresses { - private final PublicIPAddressesInner client; private final PagedListConverter converter; PublicIpAddressesImpl(final PublicIPAddressesInner client, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.converter = new PagedListConverter() { @Override public PublicIpAddress typeConvert(PublicIPAddressInner inner) { @@ -43,19 +41,19 @@ public PublicIpAddress typeConvert(PublicIPAddressInner inner) { @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.listAll(); + ServiceResponse> response = this.innerCollection.listAll(); return converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.list(groupName); + ServiceResponse> response = this.innerCollection.list(groupName); return converter.convert(response.getBody()); } @Override public PublicIpAddressImpl getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse serviceResponse = this.client.get(groupName, name); + ServiceResponse serviceResponse = this.innerCollection.get(groupName, name); return createFluentModel(serviceResponse.getBody()); } @@ -66,7 +64,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -84,11 +82,11 @@ protected PublicIpAddressImpl createFluentModel(String name) { inner.withDnsSettings(new PublicIPAddressDnsSettings()); } - return new PublicIpAddressImpl(name, inner, this.client, this.resourceManager()); + return new PublicIpAddressImpl(name, inner, this.innerCollection, this.resourceManager); } @Override protected PublicIpAddressImpl createFluentModel(PublicIPAddressInner inner) { - return new PublicIpAddressImpl(inner.id(), inner, this.client, this.resourceManager()); + return new PublicIpAddressImpl(inner.id(), inner, this.innerCollection, this.resourceManager); } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index e141bba90c3b..bc48d0792727 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -25,19 +25,20 @@ public abstract class GroupableResourcesImpl< T extends GroupableResource, ImplT extends T, - InnerT extends Resource> + InnerT extends Resource, + InnerCollectionT> implements SupportsGettingById, SupportsGettingByGroup { - private final ResourceManager resourceManager; + protected final ResourceManager resourceManager; + protected final InnerCollectionT innerCollection; - protected GroupableResourcesImpl(ResourceManager resourceManager) { + protected GroupableResourcesImpl( + ResourceManager resourceManager, + InnerCollectionT innerCollection) { this.resourceManager = resourceManager; - } - - protected ResourceManager resourceManager() { - return this.resourceManager; + this.innerCollection = innerCollection; } @Override diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index ec23799ffb3b..170603013a8f 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -30,14 +30,12 @@ * The implementation of StorageAccounts and its parent interfaces. */ class StorageAccountsImpl - extends GroupableResourcesImpl + extends GroupableResourcesImpl implements StorageAccounts { - private final StorageAccountsInner client; private final PagedListConverter converter; StorageAccountsImpl(final StorageAccountsInner client, final ResourceManager resourceManager) { - super(resourceManager); - this.client = client; + super(resourceManager, client); this.converter = new PagedListConverter() { @Override public StorageAccount typeConvert(StorageAccountInner storageAccountInner) { @@ -48,25 +46,25 @@ public StorageAccount typeConvert(StorageAccountInner storageAccountInner) { @Override public CheckNameAvailabilityResult checkNameAvailability(String name) throws CloudException, IOException { - CheckNameAvailabilityResultInner inner = client.checkNameAvailability(name).getBody(); + CheckNameAvailabilityResultInner inner = this.innerCollection.checkNameAvailability(name).getBody(); return new CheckNameAvailabilityResult(inner); } @Override public PagedList list() throws CloudException, IOException { - ServiceResponse> response = client.list(); + ServiceResponse> response = this.innerCollection.list(); return converter.convert(toPagedList(response.getBody())); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - ServiceResponse> response = client.listByResourceGroup(groupName); + ServiceResponse> response = this.innerCollection.listByResourceGroup(groupName); return converter.convert(toPagedList(response.getBody())); } @Override public StorageAccount getByGroup(String groupName, String name) throws CloudException, IOException { - ServiceResponse serviceResponse = this.client.getProperties(groupName, name); + ServiceResponse serviceResponse = this.innerCollection.getProperties(groupName, name); return createFluentModel(serviceResponse.getBody()); } @@ -77,7 +75,7 @@ public void delete(String id) throws Exception { @Override public void delete(String groupName, String name) throws Exception { - this.client.delete(groupName, name); + this.innerCollection.delete(groupName, name); } @Override @@ -101,11 +99,11 @@ public Page nextPage(String nextPageLink) throws RestExcept @Override protected StorageAccountImpl createFluentModel(String name) { - return new StorageAccountImpl(name, new StorageAccountInner(), this.client, this.resourceManager()); + return new StorageAccountImpl(name, new StorageAccountInner(), this.innerCollection, this.resourceManager); } @Override protected StorageAccountImpl createFluentModel(StorageAccountInner storageAccountInner) { - return new StorageAccountImpl(storageAccountInner.name(), storageAccountInner, this.client, this.resourceManager()); + return new StorageAccountImpl(storageAccountInner.name(), storageAccountInner, this.innerCollection, this.resourceManager); } } From 8745d3b1909772b84bb00680e0be99d60ab8fe55 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 17:32:29 -0700 Subject: [PATCH 18/20] minor javadoc violation --- .../collection/implementation/GroupableResourcesImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index bc48d0792727..36beebf950bb 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -21,6 +21,7 @@ * @param the individual resource type returned * @param the individual resource implementation * @param the wrapper inner type + * @param the inner type of the collection object */ public abstract class GroupableResourcesImpl< T extends GroupableResource, @@ -33,14 +34,14 @@ public abstract class GroupableResourcesImpl< protected final ResourceManager resourceManager; protected final InnerCollectionT innerCollection; - + protected GroupableResourcesImpl( ResourceManager resourceManager, InnerCollectionT innerCollection) { this.resourceManager = resourceManager; this.innerCollection = innerCollection; } - + @Override public abstract T getByGroup(String groupName, String name) throws CloudException, IOException; From 5a75693d55e431185ed4f9d7a6d45c5f3db17f5f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 17:35:55 -0700 Subject: [PATCH 19/20] enhancing GenericResources - GenericResources in Azure do not expose list across groups, and passing null fails, so removing .list() support - adding getByGroup() - adding getById() - enabling GenericResources to inherit from the same base class as other GroupableResources --- .../resources/GenericResources.java | 6 +- .../implementation/GenericResourcesImpl.java | 78 ++++++++++++------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java index 05bc76d2cb6f..2504b7c9312d 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/GenericResources.java @@ -7,9 +7,10 @@ package com.microsoft.azure.management.resources; import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; -import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; import java.io.IOException; import java.util.List; @@ -18,8 +19,9 @@ * Entry point to generic resources management API. */ public interface GenericResources extends - SupportsListing, SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, SupportsCreating { /** * Checks if a resource exists in a resource group. diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index 534771ceaca6..1906968a9ac3 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -11,6 +11,7 @@ import com.microsoft.azure.management.resources.GenericResources; import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.api.ResourceGroupsInner; import com.microsoft.azure.management.resources.implementation.api.ResourceManagementClientImpl; @@ -23,26 +24,20 @@ import java.util.List; /** - * An instance of this class provides access to generic resources in Azure. + * Implementation of the GenericResouces interface. + * (Internal use only) */ final class GenericResourcesImpl + extends GroupableResourcesImpl implements GenericResources { private final ResourceManagementClientImpl serviceClient; - private final ResourcesInner client; private final ResourceGroupsInner resourceGroupsInner; - private final ResourceManager resourceManager; GenericResourcesImpl(ResourceManagementClientImpl serviceClient, ResourceManager resourceManager) { + super(resourceManager, serviceClient.resources()); this.serviceClient = serviceClient; - this.client = serviceClient.resources(); this.resourceGroupsInner = serviceClient.resourceGroups(); - this.resourceManager = resourceManager; - } - - @Override - public PagedList list() throws CloudException, IOException { - return listIntern(null); } @Override @@ -55,14 +50,14 @@ public GenericResource.DefinitionBlank define(String name) { return new GenericResourceImpl( name, new GenericResourceInner(), - client, + this.innerCollection, serviceClient, this.resourceManager); } @Override public boolean checkExistence(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws IOException, CloudException { - return client.checkExistence( + return this.innerCollection.checkExistence( resourceGroupName, resourceProviderNamespace, parentResourcePath, @@ -73,11 +68,11 @@ public boolean checkExistence(String resourceGroupName, String resourceProviderN @Override public GenericResource get(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws CloudException, IOException { - GenericResourceInner inner = client.get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).getBody(); + GenericResourceInner inner = this.innerCollection.get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).getBody(); GenericResourceImpl resource = new GenericResourceImpl( resourceName, inner, - client, + this.innerCollection, serviceClient, this.resourceManager); @@ -93,30 +88,59 @@ public void moveResources(String sourceResourceGroupName, ResourceGroup targetRe ResourcesMoveInfoInner moveInfo = new ResourcesMoveInfoInner(); moveInfo.withTargetResourceGroup(targetResourceGroup.id()); moveInfo.withResources(resources); - client.moveResources(sourceResourceGroupName, moveInfo); + this.innerCollection.moveResources(sourceResourceGroupName, moveInfo); } @Override public void delete(String resourceGroupName, String resourceProviderNamespace, String parentResourcePath, String resourceType, String resourceName, String apiVersion) throws CloudException, IOException { - client.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion); + this.innerCollection.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion); } private PagedList listIntern(String groupName) throws IOException, CloudException { PagedListConverter converter = new PagedListConverter() { @Override public GenericResource typeConvert(GenericResourceInner genericResourceInner) { - return new GenericResourceImpl( - genericResourceInner.id(), - genericResourceInner, - client, - serviceClient, - resourceManager) - .withExistingGroup(ResourceUtils.groupFromResourceId(genericResourceInner.id())) - .withProviderNamespace(ResourceUtils.resourceProviderFromResourceId(genericResourceInner.id())) - .withResourceType(ResourceUtils.resourceTypeFromResourceId(genericResourceInner.id())) - .withParentResource(ResourceUtils.parentResourcePathFromResourceId(genericResourceInner.id())); - } + return createFluentModel(genericResourceInner); } }; return converter.convert(resourceGroupsInner.listResources(groupName).getBody()); } + + @Override + public GenericResource getByGroup(String groupName, String name) throws CloudException, IOException { + PagedList genericResources = this.listByGroup(groupName); + for (GenericResource resource : genericResources) { + if (resource.name().equalsIgnoreCase(name)) { + return resource; + } + } + throw new CloudException("Generic resource not found."); + } + + @Override + protected GenericResourceImpl createFluentModel(String id) { + return new GenericResourceImpl( + id, + new GenericResourceInner(), + this.innerCollection, + this.serviceClient, + this.resourceManager) + .withExistingGroup(ResourceUtils.groupFromResourceId(id)) + .withProviderNamespace(ResourceUtils.resourceProviderFromResourceId(id)) + .withResourceType(ResourceUtils.resourceTypeFromResourceId(id)) + .withParentResource(ResourceUtils.parentResourcePathFromResourceId(id)); + } + + @Override + protected GenericResourceImpl createFluentModel(GenericResourceInner inner) { + return new GenericResourceImpl( + inner.id(), + inner, + this.innerCollection, + this.serviceClient, + this.resourceManager) + .withExistingGroup(ResourceUtils.groupFromResourceId(inner.id())) + .withProviderNamespace(ResourceUtils.resourceProviderFromResourceId(inner.id())) + .withResourceType(ResourceUtils.resourceTypeFromResourceId(inner.id())) + .withParentResource(ResourceUtils.parentResourcePathFromResourceId(inner.id())); + } } From 938e22192a6b4ef246a9f42cafdaa9264d920d86 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Jun 2016 17:54:40 -0700 Subject: [PATCH 20/20] pushing converter logic from concrete collection classes into the base class to remove the significant code repetition --- .../implementation/AvailabilitySetsImpl.java | 8 -------- .../compute/implementation/VirtualMachinesImpl.java | 11 ++--------- .../implementation/NetworkInterfacesImpl.java | 13 ++----------- .../implementation/NetworkSecurityGroupsImpl.java | 12 ++---------- .../network/implementation/NetworksImpl.java | 12 ++---------- .../implementation/PublicIpAddressesImpl.java | 12 ++---------- .../implementation/GroupableResourcesImpl.java | 8 ++++++++ .../implementation/GenericResourcesImpl.java | 12 +----------- .../storage/implementation/StorageAccountsImpl.java | 12 ++---------- 9 files changed, 21 insertions(+), 79 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java index a125fa1d8fa0..30b224a4b12c 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -15,7 +15,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; import com.microsoft.rest.RestException; @@ -30,17 +29,10 @@ class AvailabilitySetsImpl extends GroupableResourcesImpl implements AvailabilitySets { - private final PagedListConverter converter; AvailabilitySetsImpl( final AvailabilitySetsInner client, final ResourceManager resourceManager) { super(resourceManager, client); - this.converter = new PagedListConverter() { - @Override - public AvailabilitySet typeConvert(AvailabilitySetInner inner) { - return createFluentModel(inner); - } - }; } @Override diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java index 370b7a99ad92..5a99abc7f6bd 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -45,7 +45,6 @@ class VirtualMachinesImpl private final ComputeManager computeManager; private final StorageManager storageManager; private final NetworkManager networkManager; - private final PagedListConverter converter; VirtualMachinesImpl(VirtualMachinesInner client, VirtualMachineSizesInner virtualMachineSizesClient, @@ -58,12 +57,6 @@ class VirtualMachinesImpl this.computeManager = computeManager; this.storageManager = storageManager; this.networkManager = networkManager; - this.converter = new PagedListConverter() { - @Override - public VirtualMachine typeConvert(VirtualMachineInner inner) { - return createFluentModel(inner); - } - }; } // Actions @@ -72,13 +65,13 @@ public VirtualMachine typeConvert(VirtualMachineInner inner) { @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = this.innerCollection.listAll(); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = this.innerCollection.list(groupName); - return converter.convert(toPagedList(response.getBody())); + return this.converter.convert(toPagedList(response.getBody())); } @Override diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java index 5db63ad7d3a7..8db262b94f0a 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkInterfacesImpl.java @@ -10,7 +10,6 @@ import com.microsoft.azure.management.network.implementation.api.NetworkInterfaceDnsSettings; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -25,32 +24,24 @@ class NetworkInterfacesImpl implements NetworkInterfaces { private final NetworkManager networkManager; - private final PagedListConverter converter; - NetworkInterfacesImpl( final NetworkInterfacesInner client, final NetworkManager networkManager, final ResourceManager resourceManager) { super(resourceManager, client); this.networkManager = networkManager; - this.converter = new PagedListConverter() { - @Override - public NetworkInterface typeConvert(NetworkInterfaceInner inner) { - return createFluentModel(inner); - } - }; } @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = innerCollection.listAll(); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = innerCollection.list(groupName); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java index e71a9d2f959e..f8085a14501f 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworkSecurityGroupsImpl.java @@ -14,7 +14,6 @@ import com.microsoft.azure.management.network.implementation.api.SecurityRuleInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -28,28 +27,21 @@ class NetworkSecurityGroupsImpl extends GroupableResourcesImpl implements NetworkSecurityGroups { - private final PagedListConverter converter; NetworkSecurityGroupsImpl(final NetworkSecurityGroupsInner client, final ResourceManager resourceManager) { super(resourceManager, client); - this.converter = new PagedListConverter() { - @Override - public NetworkSecurityGroup typeConvert(NetworkSecurityGroupInner inner) { - return createFluentModel(inner); - } - }; } @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = this.innerCollection.listAll(); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = this.innerCollection.list(groupName); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java index b916ce3d1595..5ae0c7dac950 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/NetworksImpl.java @@ -16,7 +16,6 @@ import com.microsoft.azure.management.network.implementation.api.VirtualNetworksInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -30,28 +29,21 @@ class NetworksImpl extends GroupableResourcesImpl implements Networks { - private final PagedListConverter converter; NetworksImpl(final VirtualNetworksInner client, final ResourceManager resourceManager) { super(resourceManager, client); - this.converter = new PagedListConverter() { - @Override - public Network typeConvert(VirtualNetworkInner inner) { - return createFluentModel(inner); - } - }; } @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = this.innerCollection.listAll(); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = this.innerCollection.list(groupName); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java index feccb56d6a17..f89218673521 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressesImpl.java @@ -14,7 +14,6 @@ import com.microsoft.azure.management.network.implementation.api.PublicIPAddressesInner; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.rest.ServiceResponse; @@ -27,28 +26,21 @@ class PublicIpAddressesImpl extends GroupableResourcesImpl implements PublicIpAddresses { - private final PagedListConverter converter; PublicIpAddressesImpl(final PublicIPAddressesInner client, final ResourceManager resourceManager) { super(resourceManager, client); - this.converter = new PagedListConverter() { - @Override - public PublicIpAddress typeConvert(PublicIPAddressInner inner) { - return createFluentModel(inner); - } - }; } @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = this.innerCollection.listAll(); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = this.innerCollection.list(groupName); - return converter.convert(response.getBody()); + return this.converter.convert(response.getBody()); } @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java index 36beebf950bb..3ca549a7e6e8 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; /** @@ -34,12 +35,19 @@ public abstract class GroupableResourcesImpl< protected final ResourceManager resourceManager; protected final InnerCollectionT innerCollection; + protected final PagedListConverter converter; protected GroupableResourcesImpl( ResourceManager resourceManager, InnerCollectionT innerCollection) { this.resourceManager = resourceManager; this.innerCollection = innerCollection; + this.converter = new PagedListConverter() { + @Override + public T typeConvert(InnerT inner) { + return createFluentModel(inner); + } + }; } @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java index 1906968a9ac3..7f38a4c2e463 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/GenericResourcesImpl.java @@ -12,7 +12,6 @@ import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.api.ResourceGroupsInner; import com.microsoft.azure.management.resources.implementation.api.ResourceManagementClientImpl; import com.microsoft.azure.management.resources.implementation.api.ResourcesInner; @@ -42,7 +41,7 @@ final class GenericResourcesImpl @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { - return listIntern(groupName); + return this.converter.convert(resourceGroupsInner.listResources(groupName).getBody()); } @Override @@ -96,15 +95,6 @@ public void delete(String resourceGroupName, String resourceProviderNamespace, S this.innerCollection.delete(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion); } - private PagedList listIntern(String groupName) throws IOException, CloudException { - PagedListConverter converter = new PagedListConverter() { - @Override - public GenericResource typeConvert(GenericResourceInner genericResourceInner) { - return createFluentModel(genericResourceInner); } - }; - return converter.convert(resourceGroupsInner.listResources(groupName).getBody()); - } - @Override public GenericResource getByGroup(String groupName, String name) throws CloudException, IOException { PagedList genericResources = this.listByGroup(groupName); diff --git a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java index 170603013a8f..599445d830a7 100644 --- a/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java +++ b/azure-mgmt-storage/src/main/java/com/microsoft/azure/management/storage/implementation/StorageAccountsImpl.java @@ -11,7 +11,6 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; import com.microsoft.azure.management.resources.implementation.ResourceManager; import com.microsoft.azure.management.resources.implementation.api.PageImpl; import com.microsoft.azure.management.storage.StorageAccount; @@ -32,16 +31,9 @@ class StorageAccountsImpl extends GroupableResourcesImpl implements StorageAccounts { - private final PagedListConverter converter; StorageAccountsImpl(final StorageAccountsInner client, final ResourceManager resourceManager) { super(resourceManager, client); - this.converter = new PagedListConverter() { - @Override - public StorageAccount typeConvert(StorageAccountInner storageAccountInner) { - return createFluentModel(storageAccountInner); - } - }; } @Override @@ -53,13 +45,13 @@ public CheckNameAvailabilityResult checkNameAvailability(String name) throws Clo @Override public PagedList list() throws CloudException, IOException { ServiceResponse> response = this.innerCollection.list(); - return converter.convert(toPagedList(response.getBody())); + return this.converter.convert(toPagedList(response.getBody())); } @Override public PagedList listByGroup(String groupName) throws CloudException, IOException { ServiceResponse> response = this.innerCollection.listByResourceGroup(groupName); - return converter.convert(toPagedList(response.getBody())); + return this.converter.convert(toPagedList(response.getBody())); } @Override