diff --git a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java index ea8c2fefd4c0c..341163cee8df7 100644 --- a/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java +++ b/azure-mgmt-batch/src/main/java/com/microsoft/azure/management/batch/implementation/BatchAccountsImpl.java @@ -7,6 +7,7 @@ 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.storage.implementation.StorageManager; +import rx.Observable; /** * Implementation for BatchAccounts and its parent interfaces. @@ -27,13 +28,8 @@ protected BatchAccountsImpl(BatchAccountsInner innerCollection, BatchManager man } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override 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 43b7ebc68a971..f592173d1ba07 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 @@ -9,9 +9,9 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.compute.AvailabilitySet; import com.microsoft.azure.management.compute.AvailabilitySets; -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 rx.Observable; import java.util.List; @@ -61,13 +61,8 @@ public AvailabilitySetImpl define(String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } /************************************************************** diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java index 5bed8a37ce2d9..3b234f9d4de27 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java @@ -13,6 +13,8 @@ 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.storage.implementation.StorageManager; +import rx.Observable; + import java.util.ArrayList; /** @@ -55,13 +57,8 @@ public PagedList list() { } @Override - public void delete(String id) { - this.delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @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 810d9aa250011..abdaefa25547f 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.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; import com.microsoft.azure.management.storage.implementation.StorageManager; +import rx.Observable; import rx.exceptions.Exceptions; import java.util.ArrayList; @@ -74,13 +75,8 @@ public VirtualMachine getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java index 8dd433fa34a1d..0aaaad5bbd61e 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/ServicePrincipals.java @@ -18,8 +18,7 @@ */ public interface ServicePrincipals extends SupportsCreating, - SupportsListing, - SupportsDeleting { + SupportsListing { /** * Gets the information about a service principal. * diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java index 6697418f0b0c9..e2dd820e1aee9 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/Users.java @@ -18,8 +18,7 @@ */ public interface Users extends SupportsCreating, - SupportsListing, - SupportsDeleting { + SupportsListing{ /** * Gets the information about a user. * diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java index ede66beea7fb3..421449ff024f7 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/ServicePrincipalsImpl.java @@ -44,11 +44,6 @@ public PagedList list() { return wrapList(this.innerCollection.list()); } - @Override - public void delete(String id) { - innerCollection.delete(id); - } - @Override public ServicePrincipalImpl define(String appId) { return wrapModel(appId); diff --git a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java index 6487b0f191e87..82b18c165be29 100644 --- a/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java +++ b/azure-mgmt-graph-rbac/src/main/java/com/microsoft/azure/management/graphrbac/implementation/UsersImpl.java @@ -40,11 +40,6 @@ public PagedList list() { return wrapList(this.innerCollection.list()); } - @Override - public void delete(String id) { - innerCollection.delete(id); - } - @Override public UserImpl define(String name) { return wrapModel(name); diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java index 2bc06369a87f6..e9e9fd0e649ca 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultsImpl.java @@ -14,6 +14,7 @@ import com.microsoft.azure.management.keyvault.Vaults; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; import java.util.UUID; @@ -57,13 +58,8 @@ public Vault getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java index a6b53be72d760..f7fdcfd9f5048 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/LoadBalancersImpl.java @@ -11,6 +11,7 @@ import com.microsoft.azure.management.network.LoadBalancers; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; /** * Implementation for {@link LoadBalancers}. @@ -47,13 +48,8 @@ public LoadBalancerImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @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 b3e3ece746abd..7b8703b5e1ca0 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 @@ -7,6 +7,7 @@ import com.microsoft.azure.management.network.NetworkInterfaces; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; import java.util.ArrayList; @@ -45,13 +46,8 @@ public NetworkInterface getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - this.delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @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 56cde273e9423..fcd221d7892e3 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 @@ -11,6 +11,7 @@ import com.microsoft.azure.management.network.NetworkSecurityGroups; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; import java.util.ArrayList; @@ -49,13 +50,8 @@ public NetworkSecurityGroupImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @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 a72b9a2cd25b7..d38354a18c7b0 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 @@ -13,6 +13,7 @@ import com.microsoft.azure.management.network.Networks; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; import java.util.ArrayList; @@ -51,13 +52,8 @@ public NetworkImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @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 f2f738ca09da5..c5b9eb4309287 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 @@ -12,6 +12,7 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; /** * Implementation for {@link PublicIpAddresses}. @@ -48,13 +49,8 @@ public PublicIpAddressImpl getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override diff --git a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java index 8bc144b6fbe20..1ac17aab4bf88 100644 --- a/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java +++ b/azure-mgmt-redis/src/main/java/com/microsoft/azure/management/redis/implementation/RedisCachesImpl.java @@ -12,6 +12,7 @@ import com.microsoft.azure.management.redis.RedisCaches; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import rx.Observable; /** * The implementation of RedisCaches and its parent interfaces. @@ -52,13 +53,8 @@ public RedisCache getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java index 6dacc8134db55..f11577bf867b6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java @@ -8,6 +8,9 @@ import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.apigeneration.LangDefinition.MethodConversion; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import rx.Observable; /** * Provides access to deleting a resource from Azure, identifying it by its name and its resource group. @@ -23,4 +26,21 @@ public interface SupportsDeletingByGroup { * @param name The name of the resource */ void delete(String groupName, String name); + + /** + * Asynchronously delete a resource from Azure, identifying it by its name and its resource group. + * + * @param groupName The group the resource is part of + * @param name The name of the resource + * @param callback the callback to call on success or failure + */ + ServiceCall deleteAsync(String groupName, String name, ServiceCallback callback); + + /** + * Asynchronously delete a resource from Azure, identifying it by its name and its resource group. + * + * @param groupName The group the resource is part of + * @param name The name of the resource + */ + Observable deleteAsync(String groupName, String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java index 6ef863c198987..fe6dc747893bb 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/CreatableResourcesImpl.java @@ -3,6 +3,7 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; import com.microsoft.azure.management.resources.fluentcore.model.CreatedResources; import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl; @@ -32,7 +33,10 @@ */ public abstract class CreatableResourcesImpl extends CreatableWrappersImpl - implements SupportsBatchCreation { + implements + SupportsBatchCreation, + // Assume anything creatable is deletable + SupportsDeleting { protected CreatableResourcesImpl() { } @@ -100,6 +104,21 @@ public ServiceResponse> call(CreatedResources ts) { }), callback); } + @Override + public void delete(String id) { + deleteAsync(id).toBlocking().subscribe(); + } + + @Override + public ServiceCall deleteAsync(String id, ServiceCallback callback) { + return ServiceCall.create(deleteAsync(id).map(new Func1>() { + @Override + public ServiceResponse call(Void aVoid) { + return new ServiceResponse<>(aVoid, null); + } + }), callback); + } + /** * Implements {@link CreatedResources}. * @param the type of the resources in the batch. 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 a73a476717995..79eb3064d1fca 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 @@ -7,10 +7,17 @@ import com.microsoft.azure.Resource; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +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.implementation.ManagerBase; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import rx.Observable; +import rx.functions.Func1; /** * Base class for resource collection classes. @@ -30,7 +37,8 @@ public abstract class GroupableResourcesImpl< extends CreatableResourcesImpl implements SupportsGettingById, - SupportsGettingByGroup { + SupportsGettingByGroup, + SupportsDeletingByGroup { protected final InnerCollectionT innerCollection; protected final ManagerT myManager; @@ -50,4 +58,24 @@ public T getById(String id) { ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } + + @Override + public void delete(String groupName, String name) { + deleteAsync(groupName, name).toBlocking().subscribe(); + } + + @Override + public ServiceCall deleteAsync(String groupName, String name, ServiceCallback callback) { + return ServiceCall.create(deleteAsync(groupName, name).map(new Func1>() { + @Override + public ServiceResponse call(Void aVoid) { + return new ServiceResponse<>(aVoid, null); + } + }), callback); + } + + @Override + public Observable deleteAsync(String id) { + return deleteAsync(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + } } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java index 9a1cb1721a05a..12177fd91a38c 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java @@ -7,6 +7,9 @@ package com.microsoft.azure.management.resources.fluentcore.collection; import com.microsoft.azure.management.apigeneration.LangDefinition; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import rx.Observable; /** * Provides access to deleting a resource from Azure, identifying it by its resource ID. @@ -21,4 +24,19 @@ public interface SupportsDeleting { * @param id the resource ID of the resource to delete */ void delete(String id); + + /** + * Asynchronously delete a resource from Azure, identifying it by its resource ID. + * + * @param id the resource ID of the resource to delete + * @param callback the callback on success or failure + */ + ServiceCall deleteAsync(String id, ServiceCallback callback); + + /** + * Asynchronously delete a resource from Azure, identifying it by its resource ID. + * + * @param id the resource ID of the resource to delete + */ + Observable deleteAsync(String id); } 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 3d1a3d252c081..137d58be04dde 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 @@ -13,6 +13,11 @@ import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupPagedList; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import rx.Observable; +import rx.functions.Func1; import java.util.List; @@ -73,13 +78,23 @@ public Deployment getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - this.delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + public void delete(String groupName, String name) { + deleteAsync(groupName, name).toBlocking().subscribe(); } @Override - public void delete(String groupName, String name) { - client.delete(groupName, name); + public ServiceCall deleteAsync(String groupName, String name, ServiceCallback callback) { + return ServiceCall.create(deleteAsync(groupName, name).map(new Func1>() { + @Override + public ServiceResponse call(Void aVoid) { + return new ServiceResponse<>(aVoid, null); + } + }), callback); + } + + @Override + public Observable deleteAsync(String groupName, String name) { + return client.deleteAsync(groupName, name); } @Override @@ -110,4 +125,24 @@ public Deployment getById(String id) { ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); } + + @Override + public void delete(String id) { + deleteAsync(id).toBlocking().subscribe(); + } + + @Override + public ServiceCall deleteAsync(String id, ServiceCallback callback) { + return ServiceCall.create(deleteAsync(id).map(new Func1>() { + @Override + public ServiceResponse call(Void aVoid) { + return new ServiceResponse<>(aVoid, null); + } + }), callback); + } + + @Override + public Observable deleteAsync(String id) { + return deleteAsync(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); + } } 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 d079af7d0e265..115c63fc4d00e 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 @@ -13,6 +13,7 @@ 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 rx.Observable; import java.util.List; @@ -167,6 +168,12 @@ protected GenericResourceImpl wrapModel(GenericResourceInner inner) { @Override public GenericResource getByGroup(String groupName, String name) { // Not needed, can't be supported, provided only to satisfy GroupableResourceImpl's requirements - return null; + throw new UnsupportedOperationException("Get just by resource group and name is not supported. Please use other overloads."); + } + + @Override + public Observable deleteAsync(String groupName, String name) { + // Not needed, can't be supported, provided only to satisfy GroupableResourceImpl's requirements + throw new UnsupportedOperationException("Delete just by resource group and name is not supported. Please use other overloads."); } } 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 a49210905f2e5..5f0703eb1c285 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 @@ -10,6 +10,7 @@ import com.microsoft.azure.management.resources.ResourceGroup; import com.microsoft.azure.management.resources.ResourceGroups; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableResourcesImpl; +import rx.Observable; /** * The implementation for {@link ResourceGroups} and its parent interfaces. @@ -41,8 +42,8 @@ public ResourceGroupImpl getByName(String name) { } @Override - public void delete(String name) { - client.delete(name); + public Observable deleteAsync(String name) { + return client.deleteAsync(name); } @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 a49f8014aad24..fd352a44cc8ff 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 @@ -13,6 +13,7 @@ import com.microsoft.azure.management.storage.SkuName; import com.microsoft.azure.management.storage.StorageAccount; import com.microsoft.azure.management.storage.StorageAccounts; +import rx.Observable; /** * The implementation of StorageAccounts and its parent interfaces. @@ -53,13 +54,8 @@ public StorageAccount getByGroup(String groupName, String name) { } @Override - public void delete(String id) { - delete(ResourceUtils.groupFromResourceId(id), ResourceUtils.nameFromResourceId(id)); - } - - @Override - public void delete(String groupName, String name) { - this.innerCollection.delete(groupName, name); + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); } @Override