From 10f6ad0c6416ee7b84427b30a3068fec2005e6aa Mon Sep 17 00:00:00 2001 From: YalinLi0312 Date: Wed, 24 Mar 2021 16:18:02 -0700 Subject: [PATCH 1/2] Change the accessbility to virtual for Resource.Id --- .../Azure.ResourceManager.Core/src/Resources/Resource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Resources/Resource.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Resources/Resource.cs index 86a35ac05cf77..a8638d1c689be 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Resources/Resource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Resources/Resource.cs @@ -14,7 +14,7 @@ public abstract class Resource : IEquatable, IEquatable, IComp /// /// Gets or sets the resource identifier. /// - public abstract ResourceIdentifier Id { get; protected set; } + public virtual ResourceIdentifier Id { get; protected set; } /// /// Gets the name. From 969ae3dbba133adc6123940350866f7313ba2fd0 Mon Sep 17 00:00:00 2001 From: nisha-bhatia Date: Wed, 14 Apr 2021 11:52:03 -0700 Subject: [PATCH 2/2] add token --- .../src/ExtensionResourceOperationsBase.cs | 4 ++-- .../src/GenericResource.cs | 2 +- .../src/GenericResourceOperations.cs | 12 ++++++------ .../src/ResourceGroup.cs | 2 +- .../src/ResourceGroupOperations.cs | 14 +++++++------- .../src/ResourceOperationsBase.cs | 4 ++-- .../Azure.ResourceManager.Core/src/Subscription.cs | 2 +- .../Proto.Client/authorization/RoleAssignment.cs | 2 +- .../Proto.Client/billing/BillingAccount.cs | 2 +- .../Proto.Client/compute/AvailabilitySet.cs | 6 +++--- .../Proto.Client/compute/VirtualMachine.cs | 2 +- .../Proto.Client/network/NetworkInterface.cs | 2 +- .../Proto.Client/network/NetworkSecurityGroup.cs | 2 +- .../network/NetworkSecurityGroupOperations.cs | 2 +- .../Proto.Client/network/PublicIpAddress.cs | 2 +- sdk/resourcemanager/Proto.Client/network/Subnet.cs | 2 +- .../Proto.Client/network/VirtualNetwork.cs | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ExtensionResourceOperationsBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ExtensionResourceOperationsBase.cs index 09c04fd5caa6d..df24ed207c2cb 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ExtensionResourceOperationsBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ExtensionResourceOperationsBase.cs @@ -77,9 +77,9 @@ protected ExtensionResourceOperationsBase(OperationsBase genericOperations, Reso /// Get details for this resource from the service or can be overriden to provide a cached instance. /// /// A operation for this resource. - protected virtual TOperations GetResource() + protected virtual TOperations GetResource(CancellationToken cancellationToken = default) { - return Get().Value; + return Get(cancellationToken).Value; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResource.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResource.cs index 677ca3c7bcb43..ce9d1414da352 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResource.cs @@ -31,7 +31,7 @@ internal GenericResource(ResourceOperationsBase operations, GenericResourceData public virtual GenericResourceData Data { get; } /// - protected override GenericResource GetResource() + protected override GenericResource GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs index cd23bc129417d..9d22d3af5d686 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs @@ -102,7 +102,7 @@ public async Task> StartDeleteAsync(CancellationToken can /// public ArmResponse AddTag(string key, string value, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); // Potential optimization on tags set, remove NOOP to bypass the call. resource.Data.Tags[key] = value; var apiVersion = GetApiVersion(cancellationToken); @@ -126,7 +126,7 @@ await op.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false), /// public ArmOperation StartAddTag(string key, string value, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); resource.Data.Tags[key] = value; var apiVersion = GetApiVersion(cancellationToken); return new PhArmOperation( @@ -177,7 +177,7 @@ protected override void Validate(ResourceIdentifier identifier) /// public ArmResponse SetTags(IDictionary tags, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); resource.Data.Tags.ReplaceWith(tags); var apiVersion = GetApiVersion(cancellationToken); return new PhArmResponse( @@ -200,7 +200,7 @@ await op.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false), /// public ArmOperation StartSetTags(IDictionary tags, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); resource.Data.Tags.ReplaceWith(tags); var apiVersion = GetApiVersion(cancellationToken); return new PhArmOperation( @@ -223,7 +223,7 @@ await op.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false), /// public ArmResponse RemoveTag(string key, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); resource.Data.Tags.Remove(key); var apiVersion = GetApiVersion(cancellationToken); return new PhArmResponse( @@ -246,7 +246,7 @@ await op.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false), /// public ArmOperation StartRemoveTag(string key, CancellationToken cancellationToken = default) { - GenericResource resource = GetResource(); + GenericResource resource = GetResource(cancellationToken); resource.Data.Tags.Remove(key); var apiVersion = GetApiVersion(cancellationToken); return new PhArmOperation( diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroup.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroup.cs index 96ffbc4f8ce0b..0c6d131cc6871 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroup.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroup.cs @@ -35,7 +35,7 @@ internal ResourceGroup(ResourceOperationsBase operations, ResourceGroupData reso public virtual ResourceGroupData Data { get; } /// - protected override ResourceGroup GetResource() + protected override ResourceGroup GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroupOperations.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroupOperations.cs index bfad3556ff1e2..837007ea31105 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroupOperations.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceGroupOperations.cs @@ -209,7 +209,7 @@ public virtual ArmResponse AddTag(string key, string value, Cance try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(resource.Data.Tags); patch.Tags[key] = value; @@ -264,7 +264,7 @@ public virtual ArmOperation StartAddTag(string key, string value, try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(resource.Data.Tags); patch.Tags[key] = value; @@ -380,7 +380,7 @@ public virtual ArmResponse SetTags(IDictionary ta try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(tags); return new PhArmResponse(Operations.Update(Id.Name, patch, cancellationToken), g => @@ -434,7 +434,7 @@ public virtual ArmOperation StartSetTags(IDictionary(Operations.Update(Id.Name, patch, cancellationToken), g => @@ -488,7 +488,7 @@ public virtual ArmResponse RemoveTag(string key, CancellationToke try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(resource.Data.Tags); patch.Tags.Remove(key); @@ -544,7 +544,7 @@ public virtual ArmOperation StartRemoveTag(string key, Cancellati try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(resource.Data.Tags); patch.Tags.Remove(key); @@ -571,7 +571,7 @@ public virtual async Task> StartRemoveTagAsync(strin try { - var resource = GetResource(); + var resource = GetResource(cancellationToken); var patch = new ResourceGroupPatchable(); patch.Tags.ReplaceWith(resource.Data.Tags); patch.Tags.Remove(key); diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceOperationsBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceOperationsBase.cs index 512c5de7acb6f..ca0a157c9f65b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceOperationsBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceOperationsBase.cs @@ -98,9 +98,9 @@ internal ResourceOperationsBase(ClientContext clientContext, ResourceIdentifier /// Get details for this resource from the service or can be overriden to provide a cached instance. /// /// A operation for this resource. - protected virtual TOperations GetResource() + protected virtual TOperations GetResource(CancellationToken cancellationToken = default) { - return Get().Value; + return Get(cancellationToken).Value; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Subscription.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Subscription.cs index 3b7711b6279d2..be897509c78ac 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Subscription.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Subscription.cs @@ -35,7 +35,7 @@ internal Subscription(SubscriptionOperations subscription, SubscriptionData subs public virtual SubscriptionData Data { get; } /// - protected override Subscription GetResource() + protected override Subscription GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/authorization/RoleAssignment.cs b/sdk/resourcemanager/Proto.Client/authorization/RoleAssignment.cs index 17e372564733e..0590c98bf8370 100644 --- a/sdk/resourcemanager/Proto.Client/authorization/RoleAssignment.cs +++ b/sdk/resourcemanager/Proto.Client/authorization/RoleAssignment.cs @@ -29,7 +29,7 @@ internal RoleAssignment(OperationsBase operations, RoleAssignmentData data) public RoleAssignmentData Data { get; } /// - protected override RoleAssignment GetResource() + protected override RoleAssignment GetResource(CancellationToken cancellationToken = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/billing/BillingAccount.cs b/sdk/resourcemanager/Proto.Client/billing/BillingAccount.cs index b683b8ce5d6b5..e85851b9eb439 100644 --- a/sdk/resourcemanager/Proto.Client/billing/BillingAccount.cs +++ b/sdk/resourcemanager/Proto.Client/billing/BillingAccount.cs @@ -29,7 +29,7 @@ internal BillingAccount(ResourceOperationsBase options, BillingAccountData resou public BillingAccountData Data { get; private set; } /// - protected override BillingAccount GetResource() + protected override BillingAccount GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/compute/AvailabilitySet.cs b/sdk/resourcemanager/Proto.Client/compute/AvailabilitySet.cs index ea0bd8eb82022..b1efc8d02a230 100644 --- a/sdk/resourcemanager/Proto.Client/compute/AvailabilitySet.cs +++ b/sdk/resourcemanager/Proto.Client/compute/AvailabilitySet.cs @@ -1,6 +1,6 @@ -using System.Threading; +using Azure.ResourceManager.Core; +using System.Threading; using System.Threading.Tasks; -using Azure.ResourceManager.Core; namespace Proto.Compute { @@ -26,7 +26,7 @@ internal AvailabilitySet(ResourceOperationsBase options, AvailabilitySetData res public AvailabilitySetData Data { get; private set; } /// - protected override AvailabilitySet GetResource() + protected override AvailabilitySet GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/compute/VirtualMachine.cs b/sdk/resourcemanager/Proto.Client/compute/VirtualMachine.cs index 504321feee30f..2fec3f059e30b 100644 --- a/sdk/resourcemanager/Proto.Client/compute/VirtualMachine.cs +++ b/sdk/resourcemanager/Proto.Client/compute/VirtualMachine.cs @@ -26,7 +26,7 @@ internal VirtualMachine(ResourceOperationsBase operations, VirtualMachineData re } /// - protected override VirtualMachine GetResource() + protected override VirtualMachine GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/network/NetworkInterface.cs b/sdk/resourcemanager/Proto.Client/network/NetworkInterface.cs index c5810cab61389..4492102277bc1 100644 --- a/sdk/resourcemanager/Proto.Client/network/NetworkInterface.cs +++ b/sdk/resourcemanager/Proto.Client/network/NetworkInterface.cs @@ -21,7 +21,7 @@ internal NetworkInterface(ResourceOperationsBase options, NetworkInterfaceData r public NetworkInterfaceData Data { get; private set; } /// - protected override NetworkInterface GetResource() + protected override NetworkInterface GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroup.cs b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroup.cs index e1ab1701c4ba8..b4684dadba263 100644 --- a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroup.cs +++ b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroup.cs @@ -29,7 +29,7 @@ internal NetworkSecurityGroup(ResourceOperationsBase operations, NetworkSecurity public NetworkSecurityGroupData Data { get; private set; } /// - protected override NetworkSecurityGroup GetResource() + protected override NetworkSecurityGroup GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs index f9a72e4368803..1a31336eca351 100644 --- a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs +++ b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs @@ -192,7 +192,7 @@ public async Task> StartDeleteAsync(CancellationToken can } /// - protected override NetworkSecurityGroup GetResource() + protected override NetworkSecurityGroup GetResource(CancellationToken cancellationToken = default) { return Get().Value; } diff --git a/sdk/resourcemanager/Proto.Client/network/PublicIpAddress.cs b/sdk/resourcemanager/Proto.Client/network/PublicIpAddress.cs index c59de4398485d..40bae46b8af18 100644 --- a/sdk/resourcemanager/Proto.Client/network/PublicIpAddress.cs +++ b/sdk/resourcemanager/Proto.Client/network/PublicIpAddress.cs @@ -26,7 +26,7 @@ internal PublicIpAddress(ResourceOperationsBase options, PublicIPAddressData res public PublicIPAddressData Data { get; private set; } /// - protected override PublicIpAddress GetResource() + protected override PublicIpAddress GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/network/Subnet.cs b/sdk/resourcemanager/Proto.Client/network/Subnet.cs index 46694959eb826..ac60e1b85a5a1 100644 --- a/sdk/resourcemanager/Proto.Client/network/Subnet.cs +++ b/sdk/resourcemanager/Proto.Client/network/Subnet.cs @@ -24,7 +24,7 @@ internal Subnet(ResourceOperationsBase options, SubnetData resource) public SubnetData Data { get; private set; } /// - protected override Subnet GetResource() + protected override Subnet GetResource(CancellationToken cancellation = default) { return this; } diff --git a/sdk/resourcemanager/Proto.Client/network/VirtualNetwork.cs b/sdk/resourcemanager/Proto.Client/network/VirtualNetwork.cs index 0ce79c8dffb4b..f9f92225b2017 100644 --- a/sdk/resourcemanager/Proto.Client/network/VirtualNetwork.cs +++ b/sdk/resourcemanager/Proto.Client/network/VirtualNetwork.cs @@ -26,7 +26,7 @@ internal VirtualNetwork(ResourceOperationsBase options, VirtualNetworkData resou public VirtualNetworkData Data { get; private set; } /// - protected override VirtualNetwork GetResource() + protected override VirtualNetwork GetResource(CancellationToken cancellation = default) { return this; }