diff --git a/sdk/core/Azure.Core.TestFramework/src/Instrumentation/InstrumentResultInterceptor.cs b/sdk/core/Azure.Core.TestFramework/src/Instrumentation/InstrumentResultInterceptor.cs
index f5de30d6bbcb..1c94317d018f 100644
--- a/sdk/core/Azure.Core.TestFramework/src/Instrumentation/InstrumentResultInterceptor.cs
+++ b/sdk/core/Azure.Core.TestFramework/src/Instrumentation/InstrumentResultInterceptor.cs
@@ -41,7 +41,7 @@ public void Intercept(IInvocation invocation)
if (
// Generated ARM clients will have a property containing the sub-client that ends with Operations.
- (invocation.Method.Name.StartsWith("get_") && (type.Name.EndsWith("Operations") || type.BaseType.Name.EndsWith("Operations"))) ||
+ (invocation.Method.Name.StartsWith("get_") && (type.Name.EndsWith("Operations") || (type.BaseType != null && type.BaseType.Name.EndsWith("Operations")))) ||
// Instrument the container construction methods inside Operations objects
(invocation.Method.Name.StartsWith("Get") && type.Name.EndsWith("Container")) ||
// Instrument the operations construction methods inside Operations objects
diff --git a/sdk/core/Azure.Core/tests/Azure.Core.Tests.csproj b/sdk/core/Azure.Core/tests/Azure.Core.Tests.csproj
index ac3aaf34aa81..ae7811d3b6d7 100644
--- a/sdk/core/Azure.Core/tests/Azure.Core.Tests.csproj
+++ b/sdk/core/Azure.Core/tests/Azure.Core.Tests.csproj
@@ -4,6 +4,7 @@
$(RequiredTargetFrameworks)
$(DefineConstants);HAS_INTERNALS_VISIBLE_CORE
true
+ true
diff --git a/sdk/core/Azure.Core/tests/TestClients/ArmOperationTest.cs b/sdk/core/Azure.Core/tests/TestClients/ArmOperationTest.cs
index 3cbc9db31f41..39f8e95a9ca5 100644
--- a/sdk/core/Azure.Core/tests/TestClients/ArmOperationTest.cs
+++ b/sdk/core/Azure.Core/tests/TestClients/ArmOperationTest.cs
@@ -4,69 +4,66 @@
using System;
using System.Threading;
using System.Threading.Tasks;
+using Azure.Core.TestFramework;
using Azure.ResourceManager.Core;
namespace Azure.Core.Tests
{
- public class ArmOperationTest : ArmOperation
- where T : class
+ public class ArmOperationTest : ArmOperation, IOperationSource
{
- private T _value;
+ private TestResource _value;
private bool _exceptionOnWait;
+ private OperationOrResponseInternals _operationHelper;
protected ArmOperationTest()
{
}
- public ArmOperationTest(T value, bool exceptionOnWait = false)
+ public ArmOperationTest(TestResource value, bool exceptionOnWait = false)
{
_value = value;
_exceptionOnWait = exceptionOnWait;
+ _operationHelper = new OperationOrResponseInternals(Response.FromValue(value, new MockResponse(200)));
}
public override string Id => "testId";
- public override T Value => _value;
+ public override TestResource Value => _operationHelper.Value;
- public override bool HasCompleted => true;
+ public override bool HasCompleted => _operationHelper.HasCompleted;
- public override bool HasValue => true;
+ public override bool HasValue => _operationHelper.HasValue;
- public override Response GetRawResponse()
- {
- return Response.FromValue(_value, null) as Response;
- }
+ public override Response GetRawResponse() => _operationHelper.GetRawResponse();
- public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default)
+ public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default)
{
if (_exceptionOnWait)
throw new ArgumentException("FakeArg");
- return new ValueTask>(Response.FromValue(_value, null));
+ return new ValueTask>(Response.FromValue(_value, new MockResponse(200)));
}
- public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken)
+ public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken)
{
if (_exceptionOnWait)
throw new ArgumentException("FakeArg");
- return new ValueTask>(Response.FromValue(_value, null));
+ return new ValueTask>(Response.FromValue(_value, new MockResponse(200)));
}
- public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default)
- {
- if (_exceptionOnWait)
- throw new ArgumentException("FakeArg");
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatusAsync(cancellationToken);
- return new ValueTask(Response.FromValue(_value, null) as Response);
- }
+ public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatus(cancellationToken);
- public override Response UpdateStatus(CancellationToken cancellationToken = default)
+ public TestResource CreateResult(Response response, CancellationToken cancellationToken)
{
- if (_exceptionOnWait)
- throw new ArgumentException("FakeArg");
+ return _value;
+ }
- return Response.FromValue(_value, null) as Response;
+ public ValueTask CreateResultAsync(Response response, CancellationToken cancellationToken)
+ {
+ return new ValueTask(_value);
}
}
}
diff --git a/sdk/core/Azure.Core/tests/TestClients/PhArmOperationTest.cs b/sdk/core/Azure.Core/tests/TestClients/PhArmOperationTest.cs
index a87d98ce67a8..a70a99bc5910 100644
--- a/sdk/core/Azure.Core/tests/TestClients/PhArmOperationTest.cs
+++ b/sdk/core/Azure.Core/tests/TestClients/PhArmOperationTest.cs
@@ -1,17 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core.TestFramework;
+using Azure.ResourceManager.Core;
+
namespace Azure.Core.Tests
{
- public class PhArmOperationTest : ArmOperationTest
+ public class PhArmOperationTest : ArmOperation
where T : class
{
+ private OperationOrResponseInternals _operationHelper;
+
+ public override T Value => _operationHelper.Value;
+
+ public override bool HasValue => _operationHelper.HasValue;
+
+ public override string Id => "MyId";
+
+ public override bool HasCompleted => _operationHelper.HasCompleted;
+
protected PhArmOperationTest()
{
}
- public PhArmOperationTest(T value) : base(value)
+ public PhArmOperationTest(T value)
{
+ _operationHelper = new OperationOrResponseInternals(Response.FromValue(value, new MockResponse(200)));
}
+
+ public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operationHelper.WaitForCompletionAsync(cancellationToken);
+
+ public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) => _operationHelper.WaitForCompletionAsync(pollingInterval, cancellationToken);
+
+ public override Response GetRawResponse() => _operationHelper.GetRawResponse();
+
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatusAsync(cancellationToken);
+
+ public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatus(cancellationToken);
}
}
diff --git a/sdk/core/Azure.Core/tests/TestClients/TestResourceOperations.cs b/sdk/core/Azure.Core/tests/TestClients/TestResourceOperations.cs
index 46b5116c1844..f49ac25bf2cc 100644
--- a/sdk/core/Azure.Core/tests/TestClients/TestResourceOperations.cs
+++ b/sdk/core/Azure.Core/tests/TestClients/TestResourceOperations.cs
@@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.Core.Pipeline;
+using Azure.ResourceManager.Core;
namespace Azure.Core.Tests
{
@@ -17,14 +18,14 @@ public virtual TestResourceOperations GetAnotherOperations()
return new TestResource();
}
- public virtual ArmOperationTest GetArmOperation(bool exceptionOnWait = false, CancellationToken cancellationToken = default)
+ public virtual ArmOperationTest GetArmOperation(bool exceptionOnWait = false, CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetArmOperation");
scope.Start();
try
{
- return new ArmOperationTest(new TestResource(), exceptionOnWait);
+ return new ArmOperationTest(new TestResource(), exceptionOnWait);
}
catch (Exception e)
{
@@ -33,14 +34,14 @@ public virtual ArmOperationTest GetArmOperation(bool exceptionOnWa
}
}
- public virtual Task> GetArmOperationAsync(bool exceptionOnWait = false, CancellationToken cancellationToken = default)
+ public virtual Task GetArmOperationAsync(bool exceptionOnWait = false, CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetArmOperation");
scope.Start();
try
{
- return Task.FromResult(new ArmOperationTest(new TestResource(), exceptionOnWait));
+ return Task.FromResult(new ArmOperationTest(new TestResource(), exceptionOnWait));
}
catch (Exception e)
{
@@ -81,7 +82,7 @@ public virtual Task> GetArmResponseAsync(Cancellat
}
}
- public virtual ArmOperationTest GetPhArmOperation(CancellationToken cancellationToken = default)
+ public virtual ArmOperation GetPhArmOperation(CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetPhArmOperation");
scope.Start();
@@ -97,14 +98,14 @@ public virtual ArmOperationTest GetPhArmOperation(CancellationToke
}
}
- public virtual Task> GetPhArmOperationAsync(CancellationToken cancellationToken = default)
+ public virtual Task> GetPhArmOperationAsync(CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetPhArmOperation");
scope.Start();
try
{
- return Task.FromResult>(new PhArmOperationTest(new TestResource()));
+ return Task.FromResult>(new PhArmOperationTest(new TestResource()));
}
catch (Exception e)
{
@@ -177,7 +178,7 @@ public virtual Task> GetArmResponseExceptionAsync(
}
}
- public virtual ArmOperationTest GetArmOperationException(CancellationToken cancellationToken = default)
+ public virtual ArmOperationTest GetArmOperationException(CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetArmOperationException");
scope.Start();
@@ -193,7 +194,7 @@ public virtual ArmOperationTest GetArmOperationException(Cancellat
}
}
- public virtual Task> GetArmOperationExceptionAsync(CancellationToken cancellationToken = default)
+ public virtual Task GetArmOperationExceptionAsync(CancellationToken cancellationToken = default)
{
using var scope = _diagnostic.CreateScope("TestResourceOperations.GetArmOperationException");
scope.Start();
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmOperation.cs
deleted file mode 100644
index c874438b64ac..000000000000
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmOperation.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Azure.Core;
-
-namespace Azure.ResourceManager.Core
-{
- ///
- /// Abstract class for long-running or synchronous applications.
- ///
- /// The to return representing the result of the ArmOperation.
- public abstract class ArmOperation : Operation
- where TOperations : class
- {
- ///
- /// Initializes a new instance of the class for mocking.
- ///
- protected ArmOperation()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The representing the result of the ArmOperation.
- protected ArmOperation(TOperations syncValue)
- {
- CompletedSynchronously = syncValue != null;
- SyncValue = syncValue;
- }
-
- ///
- /// Gets a value indicating whether or not the operation completed synchronously.
- ///
- protected bool CompletedSynchronously { get; }
-
- ///
- /// Gets the representing the result of the ArmOperation.
- ///
- protected TOperations SyncValue { get; }
-
- ///
- /// Waits for the completion of the long running operations.
- ///
- /// A token to allow the caller to cancel the call to the service. The default value is .
- /// A response with the operation for this resource.
- ///
- /// Details on long running operation object.
- ///
- public Response WaitForCompletion(CancellationToken cancellationToken = default)
- {
- return WaitForCompletion(OperationHelpers.DefaultPollingInterval.Seconds, cancellationToken);
- }
-
- ///
- /// Waits for the completion of the long running operations.
- ///
- /// The polling interval in seconds to check for status.
- /// A token to allow the caller to cancel the call to the service. The default value is .
- /// A response with the operation for this resource.
- ///
- /// Details on long running operation object.
- ///
- public Response WaitForCompletion(int pollingInterval, CancellationToken cancellationToken = default)
- {
- var polling = TimeSpan.FromSeconds(pollingInterval);
- while (true)
- {
- UpdateStatus(cancellationToken);
- if (HasCompleted)
- {
- Response response = Response.FromValue(Value, GetRawResponse());
- return new PhArmResponse(response, old => old);
- }
-
- Task.Delay(pollingInterval, cancellationToken).Wait(cancellationToken);
- }
- }
- }
-}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs
deleted file mode 100644
index c9f4e005822d..000000000000
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-using System;
-
-namespace Azure.ResourceManager.Core
-{
- ///
- /// A class representing a response object from azure resource manager service.
- ///
- public sealed class ArmResponse : ArmResponse
- {
- private readonly Response _response;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The azure response object to wrap.
- /// If is null.
- public ArmResponse(Response response)
- {
- if (response is null)
- throw new ArgumentNullException(nameof(response));
-
- _response = response;
- }
-
- ///
- public override Response Value => _response;
-
- ///
- public override Response GetRawResponse()
- {
- return _response;
- }
- }
-
- ///
- /// A class representing a response object from azure resource manager service.
- ///
- /// The operations object return by the api call.
- [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Allowed when we have a generic version of the same type")]
- public abstract class ArmResponse : Response
- {
- }
-}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs
deleted file mode 100644
index f0d24e3e714e..000000000000
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Azure.ResourceManager.Core
-{
- ///
- /// Generic ARM long running operation class for operations with no returned value
- ///
- public sealed class ArmVoidOperation : ArmOperation
- {
- private readonly Operation _wrapped;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The operation that has a response which has no body.
- public ArmVoidOperation(Operation other)
- : base(null)
- {
- if (other is null)
- throw new ArgumentNullException(nameof(other));
-
- _wrapped = other;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The response which has no body.
- public ArmVoidOperation(Response other)
- : base(other)
- {
- if (other is null)
- throw new ArgumentNullException(nameof(other));
- }
-
- ///
- public override string Id => _wrapped?.Id;
-
- ///
- public override Response Value => SyncValue;
-
- ///
- public override bool HasCompleted => CompletedSynchronously || _wrapped.HasCompleted;
-
- ///
- public override bool HasValue => CompletedSynchronously || _wrapped.HasValue;
-
- ///
- public override Response GetRawResponse()
- {
- return CompletedSynchronously ? SyncValue : _wrapped.GetRawResponse();
- }
-
- ///
- public override Response UpdateStatus(CancellationToken cancellationToken = default)
- {
- return CompletedSynchronously ? SyncValue : _wrapped.UpdateStatus(cancellationToken);
- }
-
- ///
- public override async ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default)
- {
- return CompletedSynchronously ? SyncValue : await _wrapped.UpdateStatusAsync(cancellationToken).ConfigureAwait(false);
- }
-
- ///
- public override async ValueTask> WaitForCompletionAsync(
- CancellationToken cancellationToken = default)
- {
- return CompletedSynchronously
- ? new WrappingResponse(SyncValue)
- : await _wrapped.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
- }
-
- ///
- public override async ValueTask> WaitForCompletionAsync(
- TimeSpan pollingInterval,
- CancellationToken cancellationToken)
- {
- return CompletedSynchronously
- ? new WrappingResponse(SyncValue)
- : await _wrapped.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);
- }
-
- ///
- /// A class which wraps a response with no body.
- ///
- internal class WrappingResponse : ArmResponse
- {
- private readonly Response _wrapped;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The response object to wrap.
- public WrappingResponse(Response wrapped)
- {
- _wrapped = wrapped;
- }
-
- ///
- public override Response Value => _wrapped;
-
- ///
- public override Response GetRawResponse()
- {
- return _wrapped;
- }
- }
- }
-}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/UpdateResourceGroupOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/UpdateResourceGroupOperation.cs
new file mode 100644
index 000000000000..86b8bea8bbd5
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Generated/UpdateResourceGroupOperation.cs
@@ -0,0 +1,64 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System.Text.Json;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.ResourceManager.Core
+{
+ internal class UpdateResourceGroupOperation : ArmOperation, IOperationSource
+ {
+ private readonly ResourceOperationsBase _operations;
+ private readonly OperationOrResponseInternals _operationHelper;
+
+ protected UpdateResourceGroupOperation()
+ {
+ }
+
+ internal UpdateResourceGroupOperation(ResourceOperationsBase operations, ArmResponse response)
+ {
+ _operationHelper = new OperationOrResponseInternals(response);
+ _operations = operations;
+ }
+
+ public override ResourceGroup Value => _operationHelper.Value;
+
+ public override bool HasValue => _operationHelper.HasValue;
+
+ public override string Id => throw new System.NotImplementedException();
+
+ public override bool HasCompleted => _operationHelper.HasCompleted;
+
+ public override Response GetRawResponse() => _operationHelper.GetRawResponse();
+
+ public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatus(cancellationToken);
+
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operationHelper.UpdateStatusAsync(cancellationToken);
+
+ public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operationHelper.WaitForCompletionAsync(cancellationToken);
+
+ public override ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, CancellationToken cancellationToken) => _operationHelper.WaitForCompletionAsync(pollingInterval, cancellationToken);
+
+ ResourceGroup IOperationSource.CreateResult(Response response, CancellationToken cancellationToken)
+ {
+ using var document = JsonDocument.Parse(response.ContentStream);
+ return GetResourceGrouop(document);
+ }
+
+ async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken)
+ {
+ using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ return GetResourceGrouop(document);
+ }
+
+ private ResourceGroup GetResourceGrouop(JsonDocument document)
+ {
+ var method = typeof(ResourceManager.Resources.Models.ResourceGroup).GetMethod("DeserializeResourceGroup", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+ var obj = method.Invoke(null, new object[] { document.RootElement });
+ return new ResourceGroup(_operations, new ResourceGroupData(obj as ResourceManager.Resources.Models.ResourceGroup));
+ }
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs
index 9d22d3af5d68..921734c7ce42 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/GenericResourceOperations.cs
@@ -51,9 +51,9 @@ private ResourcesOperations Operations
///
/// A token allowing immediate cancellation of any blocking call performed during the deletion.
/// The status of the delete operation.
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDeleteById(Id, GetApiVersion(cancellationToken), cancellationToken).WaitForCompletion(cancellationToken));
+ return ArmResponse.FromResponse(Operations.StartDeleteById(Id, GetApiVersion(cancellationToken), cancellationToken).WaitForCompletion(cancellationToken));
}
///
@@ -61,11 +61,11 @@ public ArmResponse Delete(CancellationToken cancellationToken = defaul
///
/// A token allowing immediate cancellation of any blocking call performed during the deletion.
/// A that on completion returns the status of the delete operation.
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
var operation = await Operations.StartDeleteByIdAsync(Id, await GetApiVersionAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);
var result = await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
- return new ArmResponse(result);
+ return ArmResponse.FromResponse(result);
}
///
@@ -77,9 +77,9 @@ public async Task> DeleteAsync(CancellationToken cancellat
///
/// Details on long running operation object.
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDeleteById(Id, GetApiVersion(cancellationToken), cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDeleteById(Id, GetApiVersion(cancellationToken), cancellationToken));
}
///
@@ -93,17 +93,16 @@ public ArmOperation StartDelete(CancellationToken cancellationToken =
///
/// Details on long running operation object.
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
var operation = await Operations.StartDeleteByIdAsync(Id, await GetApiVersionAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);
- return new ArmVoidOperation(operation);
+ return new PhVoidArmOperation(operation);
}
///
public ArmResponse AddTag(string key, string value, CancellationToken cancellationToken = default)
{
GenericResource resource = GetResource(cancellationToken);
- // Potential optimization on tags set, remove NOOP to bypass the call.
resource.Data.Tags[key] = value;
var apiVersion = GetApiVersion(cancellationToken);
return new PhArmResponse(
@@ -130,7 +129,7 @@ public ArmOperation StartAddTag(string key, string value, Cance
resource.Data.Tags[key] = value;
var apiVersion = GetApiVersion(cancellationToken);
return new PhArmOperation(
- Operations.StartUpdateById(Id, apiVersion, resource.Data, cancellationToken).WaitForCompletionAsync(cancellationToken).EnsureCompleted(),
+ Operations.StartUpdateById(Id, apiVersion, resource.Data, cancellationToken),
v => new GenericResource(this, new GenericResourceData(v)));
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/IDeletableResource.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/IDeletableResource.cs
index 782049e856f9..f77a93d5dedf 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/IDeletableResource.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/IDeletableResource.cs
@@ -16,14 +16,14 @@ public interface IDeletableResource
///
/// A token allowing immediate cancellation of any blocking call performed during the deletion.
/// The status of the delete operation.
- ArmResponse Delete(CancellationToken cancellationToken = default);
+ ArmResponse Delete(CancellationToken cancellationToken = default);
///
/// Delete the resource.
///
/// A token allowing immediate cancellation of any blocking call performed during the deletion.
/// A that on completion returns the status of the delete operation.
- Task> DeleteAsync(CancellationToken cancellationToken = default);
+ Task DeleteAsync(CancellationToken cancellationToken = default);
///
/// Delete the resource.
@@ -34,7 +34,7 @@ public interface IDeletableResource
///
/// Details on long running operation object.
///
- ArmOperation StartDelete(CancellationToken cancellationToken = default);
+ ArmOperation StartDelete(CancellationToken cancellationToken = default);
///
/// Delete the resource. This call returns a Task that blocks until the delete operation is accepted on the service.
@@ -47,6 +47,6 @@ public interface IDeletableResource
///
/// Details on long running operation object.
///
- Task> StartDeleteAsync(CancellationToken cancellationToken = default);
+ Task StartDeleteAsync(CancellationToken cancellationToken = default);
}
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/ArmOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/ArmOperation.cs
new file mode 100644
index 000000000000..76f0509ab5a7
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/ArmOperation.cs
@@ -0,0 +1,100 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Core
+{
+ ///
+ /// Abstract class for long-running or synchronous applications.
+ ///
+ public abstract class ArmOperation : Operation
+ {
+ ///
+ /// Initializes a new instance of the class for mocking.
+ ///
+ protected ArmOperation()
+ {
+ }
+
+ ///
+ /// Waits for the completion of the long running operations.
+ ///
+ /// A token to allow the caller to cancel the call to the service. The default value is .
+ /// The response with the final state of the operation.
+ public virtual Response WaitForCompletion(CancellationToken cancellationToken = default)
+ {
+ return WaitForCompletion(OperationInternals.DefaultPollingInterval, cancellationToken);
+ }
+
+ ///
+ /// Waits for the completion of the long running operations.
+ ///
+ /// The polling interval to check for status.
+ /// A token to allow the caller to cancel the call to the service. The default value is .
+ /// The response with the final state of the operation.
+ public virtual Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default)
+ {
+ while (true)
+ {
+ UpdateStatus(cancellationToken);
+ if (HasCompleted)
+ {
+ return new ArmVoidResponse(GetRawResponse());
+ }
+
+ Task.Delay(pollingInterval, cancellationToken).Wait(cancellationToken);
+ }
+ }
+ }
+
+ ///
+ /// Abstract class for long-running or synchronous applications.
+ ///
+ /// The to return representing the result of the ArmOperation.
+#pragma warning disable SA1402 // File may only contain a single type
+ public abstract class ArmOperation : Operation
+ where TOperations : notnull
+#pragma warning restore SA1402 // File may only contain a single type
+ {
+ ///
+ /// Initializes a new instance of the class for mocking.
+ ///
+ protected ArmOperation()
+ {
+ }
+
+ ///
+ /// Waits for the completion of the long running operations.
+ ///
+ /// A token to allow the caller to cancel the call to the service. The default value is .
+ /// The response with the final state of the operation.
+ public virtual Response WaitForCompletion(CancellationToken cancellationToken = default)
+ {
+ return WaitForCompletion(OperationInternals.DefaultPollingInterval, cancellationToken);
+ }
+
+ ///
+ /// Waits for the completion of the long running operations.
+ ///
+ /// The polling interval to check for status.
+ /// A token to allow the caller to cancel the call to the service. The default value is .
+ /// The response with the final state of the operation.
+ public virtual Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default)
+ {
+ while (true)
+ {
+ UpdateStatus(cancellationToken);
+ if (HasCompleted)
+ {
+ return Response.FromValue(Value, GetRawResponse()) as ArmResponse;
+ }
+
+ Task.Delay(pollingInterval, cancellationToken).Wait(cancellationToken);
+ }
+ }
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhArmOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhArmOperation.cs
new file mode 100644
index 000000000000..b0f9777dd927
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhArmOperation.cs
@@ -0,0 +1,136 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Core
+{
+ ///
+ /// A class representing an arm operation wrapper object.
+ ///
+ /// The to convert TModel into.
+ /// The model returned by existing Operation methods.
+ public class PhArmOperation : ArmOperation
+ where TOperations : class
+ where TModel : class
+ {
+ private readonly Func _converter;
+ private readonly Operation _wrappedOperation;
+ private readonly ArmOperation _wrappedResponseOperation;
+
+ ///
+ /// Initializes a new instance of the class for mocking.
+ ///
+ protected PhArmOperation()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The results to wrap.
+ /// The function used to convert from existing type to new type.
+ public PhArmOperation(Operation wrapped, Func converter)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ if (converter is null)
+ throw new ArgumentNullException(nameof(converter));
+
+ _wrappedOperation = wrapped;
+ _converter = converter;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The results to wrap.
+ /// The function used to convert from existing type to new type.
+ public PhArmOperation(Response wrapped, Func converter)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ if (converter is null)
+ throw new ArgumentNullException(nameof(converter));
+
+ _wrappedResponseOperation = new PhValueArmOperation(wrapped);
+ _converter = converter;
+ }
+
+ private bool _doesWrapOperation => _wrappedResponseOperation is null;
+
+ ///
+ public override string Id => _wrappedOperation?.Id;
+
+ ///
+ public override TOperations Value => _converter(_doesWrapOperation ? _wrappedOperation.Value : _wrappedResponseOperation.Value);
+
+ ///
+ public override bool HasCompleted => _doesWrapOperation ? _wrappedOperation.HasCompleted : _wrappedResponseOperation.HasCompleted;
+
+ ///
+ public override bool HasValue => _doesWrapOperation ? _wrappedOperation.HasValue : _wrappedResponseOperation.HasValue;
+
+ ///
+ public override Response GetRawResponse()
+ {
+ return _doesWrapOperation ? _wrappedOperation.GetRawResponse() : _wrappedResponseOperation.GetRawResponse();
+ }
+
+ ///
+ public override Response UpdateStatus(CancellationToken cancellationToken = default)
+ {
+ return _doesWrapOperation ? _wrappedOperation.UpdateStatus(cancellationToken) : _wrappedResponseOperation.UpdateStatus(cancellationToken);
+ }
+
+ ///
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default)
+ {
+ return _doesWrapOperation
+ ? _wrappedOperation.UpdateStatusAsync(cancellationToken)
+ : _wrappedResponseOperation.UpdateStatusAsync(cancellationToken);
+ }
+
+ ///
+ public override async ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default)
+ {
+ var task = WaitForCompletionAsync(OperationInternals.DefaultPollingInterval, cancellationToken);
+ return await task.ConfigureAwait(false);
+ }
+
+ ///
+ public override async ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken)
+ {
+ var value = _doesWrapOperation
+ ? await _wrappedOperation.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false)
+ : await _wrappedResponseOperation.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(_converter(value.Value), GetRawResponse());
+ }
+
+ ///
+ public override Response WaitForCompletion(CancellationToken cancellationToken = default)
+ {
+ return WaitForCompletion(OperationInternals.DefaultPollingInterval, cancellationToken);
+ }
+
+ ///
+ public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default)
+ {
+ while (true)
+ {
+ UpdateStatus(cancellationToken);
+ if (HasCompleted)
+ {
+ return Response.FromValue(Value, GetRawResponse()) as ArmResponse;
+ }
+
+ Task.Delay(pollingInterval, cancellationToken).Wait(cancellationToken);
+ }
+ }
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhValueArmOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhValueArmOperation.cs
new file mode 100644
index 000000000000..91d7a97836a2
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhValueArmOperation.cs
@@ -0,0 +1,71 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Core
+{
+ ///
+ /// A class representing an arm operation wrapper object.
+ ///
+ internal class PhValueArmOperation : ArmOperation
+ where TOperations : class
+ {
+ private readonly Operation _wrappedOperation;
+ private readonly OperationOrResponseInternals _wrappedResponseOperation;
+
+ ///
+ /// Initializes a new instance of the class for mocking.
+ ///
+ protected PhValueArmOperation()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the .
+ ///
+ /// The operation object to wrap.
+ public PhValueArmOperation(Operation wrapped)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ _wrappedOperation = wrapped;
+ }
+
+ ///
+ /// Initializes a new instance of the .
+ ///
+ /// The response object to wrap.
+ public PhValueArmOperation(Response wrapped)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ _wrappedResponseOperation = new OperationOrResponseInternals(wrapped);
+ }
+
+ private bool _doesWrapOperation => _wrappedResponseOperation is null;
+
+ public override TOperations Value => _doesWrapOperation ? _wrappedOperation.Value : _wrappedResponseOperation.Value;
+
+ public override bool HasValue => _doesWrapOperation ? _wrappedOperation.HasValue : _wrappedResponseOperation.HasValue;
+
+ public override string Id => _wrappedOperation?.Id;
+
+ public override bool HasCompleted => _doesWrapOperation ? _wrappedOperation.HasCompleted : _wrappedResponseOperation.HasCompleted;
+
+ public override Response GetRawResponse() => _doesWrapOperation? _wrappedOperation.GetRawResponse() : _wrappedResponseOperation.GetRawResponse();
+
+ public override Response UpdateStatus(CancellationToken cancellationToken = default) => _doesWrapOperation ? _wrappedOperation.UpdateStatus(cancellationToken) : _wrappedResponseOperation.UpdateStatus(cancellationToken);
+
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _doesWrapOperation ? _wrappedOperation.UpdateStatusAsync(cancellationToken) : _wrappedResponseOperation.UpdateStatusAsync(cancellationToken);
+
+ public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _doesWrapOperation ? _wrappedOperation.WaitForCompletionAsync(cancellationToken) : _wrappedResponseOperation.WaitForCompletionAsync(cancellationToken);
+
+ public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) => _doesWrapOperation ? _wrappedOperation.WaitForCompletionAsync(pollingInterval, cancellationToken) : _wrappedResponseOperation.WaitForCompletionAsync(pollingInterval, cancellationToken);
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhVoidArmOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhVoidArmOperation.cs
new file mode 100644
index 000000000000..23be0560b60d
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Operation/PhVoidArmOperation.cs
@@ -0,0 +1,90 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Core
+{
+ ///
+ /// A class representing an arm operation wrapper object.
+ ///
+ public class PhVoidArmOperation : ArmOperation
+ {
+ private readonly Operation _wrappedOperation;
+ private readonly OperationOrResponseInternals _wrappedResponseOperation;
+
+ ///
+ /// Initializes a new instance of the class for mocking.
+ ///
+ protected PhVoidArmOperation()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The results to wrap.
+ public PhVoidArmOperation(Operation wrapped)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ _wrappedOperation = wrapped;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The results to wrap.
+ public PhVoidArmOperation(Response wrapped)
+ {
+ if (wrapped is null)
+ throw new ArgumentNullException(nameof(wrapped));
+
+ _wrappedResponseOperation = new OperationOrResponseInternals(Response.FromValue(wrapped, wrapped));
+ }
+
+ private bool _doesWrapOperation => _wrappedResponseOperation is null;
+
+ ///
+ public override string Id => _wrappedOperation?.Id;
+
+ ///
+ public override bool HasCompleted => _doesWrapOperation ? _wrappedOperation.HasCompleted : _wrappedResponseOperation.HasCompleted;
+
+ ///
+ public override Response GetRawResponse() => _doesWrapOperation ? _wrappedOperation.GetRawResponse() : _wrappedResponseOperation.GetRawResponse();
+
+ ///
+ public override Response UpdateStatus(CancellationToken cancellationToken = default) => _doesWrapOperation ? _wrappedOperation.UpdateStatus(cancellationToken) : _wrappedResponseOperation.UpdateStatus(cancellationToken);
+
+ ///
+ public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _doesWrapOperation ? _wrappedOperation.UpdateStatusAsync(cancellationToken) : _wrappedResponseOperation.UpdateStatusAsync(cancellationToken);
+
+ ///
+ public override async ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default)
+ {
+ var task = WaitForCompletionResponseAsync(OperationInternals
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A that on completion returns a response with the operation for this resource.
- public virtual async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ /// A that on completion returns a response with the operation for this resource.
+ public virtual async Task DeleteAsync(CancellationToken cancellationToken = default)
{
using var scope = Diagnostics.CreateScope("ResourceGroupOperations.Delete");
scope.Start();
try
{
- return new ArmResponse(await Operations.StartDelete(Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
+ return ArmResponse.FromResponse(await Operations.StartDelete(Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
}
catch (Exception e)
{
@@ -126,14 +126,14 @@ public virtual async Task> DeleteAsync(CancellationToken c
///
/// Details on long running operation object.
///
- public virtual ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public virtual ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
using var scope = Diagnostics.CreateScope("ResourceGroupOperations.StartDelete");
scope.Start();
try
{
- return new ArmVoidOperation(Operations.StartDelete(Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.Name, cancellationToken));
}
catch (Exception e)
{
@@ -150,14 +150,14 @@ public virtual ArmOperation StartDelete(CancellationToken cancellation
///
/// Details on long running operation object.
///
- public virtual async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public virtual async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
using var scope = Diagnostics.CreateScope("ResourceGroupOperations.StartDelete");
scope.Start();
try
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.Name, cancellationToken).ConfigureAwait(false));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.Name, cancellationToken).ConfigureAwait(false));
}
catch (Exception e)
{
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmResponse.cs
new file mode 100644
index 000000000000..f647cd14422b
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmResponse.cs
@@ -0,0 +1,86 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+
+namespace Azure.ResourceManager.Core
+{
+ ///
+ /// A class representing a response object from azure resource manager service.
+ ///
+ public abstract class ArmResponse : Response
+ {
+ ///
+ /// Creates a new instance of with the provided value and HTTP response.
+ ///
+ /// The type of the value.
+ /// The value.
+ /// The HTTP response.
+ /// A new instance of with the provided value and HTTP response.
+ /// Throws if response or value are null.
+ public static ArmResponse FromValue(TOperations value, ArmResponse response)
+ {
+ if (value is null)
+ throw new ArgumentNullException(nameof(value));
+
+ if (response is null)
+ throw new ArgumentNullException(nameof(response));
+
+ return new ArmValueResponse(response, value);
+ }
+
+ ///
+ /// Creates a new instance of with the provided value and HTTP response.
+ ///
+ /// The HTTP response.
+ /// A new instance of with the provided value and HTTP response.
+ /// Throws if response is null.
+ public static ArmResponse FromResponse(Response response)
+ {
+ if (response is null)
+ throw new ArgumentNullException(nameof(response));
+
+ return new ArmVoidResponse(response);
+ }
+
+ ///
+ /// Gets the correlation id from x-ms-correlation-id.
+ ///
+ public string CorrelationId
+ {
+ get
+ {
+ string correlationId = null;
+ Headers.TryGetValue("x-ms-correlation-id", out correlationId);
+ return correlationId;
+ }
+ }
+ }
+
+ ///
+ /// A class representing a response object from azure resource manager service.
+ ///
+ /// The operations object return by the api call.
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Allowed when we have a generic version of the same type")]
+ public abstract class ArmResponse : Response
+ {
+ ///
+ /// Returns the value of this object.
+ ///
+ /// The instance.
+ public static implicit operator TOperations(ArmResponse response) => response.Value;
+
+ ///
+ /// Gets the correlation id from x-ms-correlation-id.
+ ///
+ public string CorrelationId
+ {
+ get
+ {
+ string correlationId = null;
+ GetRawResponse().Headers.TryGetValue("x-ms-correlation-id", out correlationId);
+ return correlationId;
+ }
+ }
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmValueResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmValueResponse.cs
new file mode 100644
index 000000000000..d3494f60cca7
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmValueResponse.cs
@@ -0,0 +1,28 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+
+namespace Azure.ResourceManager.Core
+{
+ internal class ArmValueResponse : ArmResponse
+ {
+ private readonly ArmResponse _response;
+
+ public ArmValueResponse(ArmResponse response, TOperations value)
+ {
+ if (response is null)
+ throw new ArgumentNullException(nameof(response));
+
+ if (value is null)
+ throw new ArgumentNullException(nameof(value));
+
+ _response = response;
+ Value = value;
+ }
+
+ public override TOperations Value { get; }
+
+ public override Response GetRawResponse() => _response;
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmVoidResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmVoidResponse.cs
new file mode 100644
index 000000000000..a1bdfd00e967
--- /dev/null
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/ArmVoidResponse.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Core
+{
+ internal class ArmVoidResponse : ArmResponse
+ {
+ private readonly Response _response;
+
+ public ArmVoidResponse(Response response)
+ {
+ if (response is null)
+ throw new ArgumentNullException(nameof(response));
+
+ _response = response;
+ }
+
+ ///
+ public override int Status => _response.Status;
+
+ ///
+ public override string ReasonPhrase => _response.ReasonPhrase;
+
+ ///
+ public override Stream ContentStream
+ {
+ get => _response.ContentStream;
+ set => _response.ContentStream = value;
+ }
+
+ ///
+ public override string ClientRequestId
+ {
+ get => _response.ClientRequestId;
+ set => _response.ClientRequestId = value;
+ }
+
+ ///
+ public override void Dispose() => _response.Dispose();
+
+ ///
+ protected override bool ContainsHeader(string name) => _response.Headers.Contains(name);
+
+ ///
+ protected override IEnumerable EnumerateHeaders() => _response.Headers;
+
+ ///
+ protected override bool TryGetHeader(string name, out string value) => _response.Headers.TryGetValue(name, out value);
+
+ ///
+ protected override bool TryGetHeaderValues(string name, out IEnumerable values) => _response.Headers.TryGetValues(name, out values);
+ }
+}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhArmResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/PhArmResponse.cs
similarity index 100%
rename from sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhArmResponse.cs
rename to sdk/resourcemanager/Azure.ResourceManager.Core/src/Response/PhArmResponse.cs
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/GenericResourceTests.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/GenericResourceTests.cs
index 413d52b711df..e2d08c7557dc 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/GenericResourceTests.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/GenericResourceTests.cs
@@ -26,7 +26,7 @@ public async Task LocalOneTimeSetup()
{
_rgName = SessionRecording.GenerateAssetName("testRg-");
var subscription = await GlobalClient.GetSubscriptions().TryGetAsync(SessionEnvironment.SubscriptionId);
- _ = subscription.GetResourceGroups().Construct(_location).StartCreateOrUpdateAsync(_rgName).ConfigureAwait(false).GetAwaiter().GetResult().Value;
+ _ = await subscription.GetResourceGroups().Construct(_location).StartCreateOrUpdateAsync(_rgName).ConfigureAwait(false);
StopSessionRecording();
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ResourceGroupOperationsTests.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ResourceGroupOperationsTests.cs
index 379c2ff91826..51e8b349c248 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ResourceGroupOperationsTests.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ResourceGroupOperationsTests.cs
@@ -31,7 +31,7 @@ public async Task StartDeleteRg()
var rgOp = await Client.DefaultSubscription.GetResourceGroups().Construct(LocationData.WestUS2).StartCreateOrUpdateAsync(Recording.GenerateAssetName("testrg"));
ResourceGroup rg = await rgOp.WaitForCompletionAsync();
var deleteOp = await rg.StartDeleteAsync();
- await deleteOp.WaitForCompletionAsync();
+ await deleteOp.WaitForCompletionResponseAsync();
}
[TestCase]
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ArmResponseTests.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ArmResponseTests.cs
index 06e502e0ed5f..868671e7a9c3 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ArmResponseTests.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ArmResponseTests.cs
@@ -12,8 +12,7 @@ public class ArmResponseTests
[TestCase]
public void TestArmResponseParamCheck()
{
- Assert.Throws(() => { new ArmResponse(null); });
-
+ Assert.Throws(() => { ArmResponse.FromResponse(null); });
}
}
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ResourceTypeFilterTests.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ResourceTypeFilterTests.cs
index 208c970bf67b..7aa0b03b0063 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ResourceTypeFilterTests.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Unit/ResourceTypeFilterTests.cs
@@ -13,8 +13,8 @@ public class ResourceTypeFilterTests
[TestCase]
public void TestResourceTypeFilterParamCheck()
{
- Assert.Throws(() => { new ArmVoidOperation((Operation)null); });
- Assert.Throws(() => { new ArmVoidOperation((Response)null); });
+ Assert.Throws(() => { new PhVoidArmOperation((Operation)null); });
+ Assert.Throws(() => { new PhVoidArmOperation((Response)null); });
}
}
}
diff --git a/sdk/resourcemanager/Proto.Client/authorization/RoleAssignmentOperations.cs b/sdk/resourcemanager/Proto.Client/authorization/RoleAssignmentOperations.cs
index adc08ef924d5..445c5b9a24d0 100644
--- a/sdk/resourcemanager/Proto.Client/authorization/RoleAssignmentOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/authorization/RoleAssignmentOperations.cs
@@ -62,27 +62,27 @@ internal RoleAssignmentOperations(OperationsBase operation, ResourceIdentifier i
private RoleAssignmentsOperations Operations { get; }
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.DeleteById(Id, cancellationToken).GetRawResponse());
+ return ArmResponse.FromResponse(Operations.DeleteById(Id, cancellationToken).GetRawResponse());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.DeleteByIdAsync(Id, cancellationToken)).GetRawResponse());
+ return ArmResponse.FromResponse((await Operations.DeleteByIdAsync(Id, cancellationToken)).GetRawResponse());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.DeleteById(Id, cancellationToken).GetRawResponse());
+ return new PhVoidArmOperation(Operations.DeleteById(Id, cancellationToken).GetRawResponse());
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation((await Operations.DeleteByIdAsync(Id, cancellationToken)).GetRawResponse());
+ return new PhVoidArmOperation((await Operations.DeleteByIdAsync(Id, cancellationToken)).GetRawResponse());
}
///
diff --git a/sdk/resourcemanager/Proto.Client/compute/AvailabilitySetOperations.cs b/sdk/resourcemanager/Proto.Client/compute/AvailabilitySetOperations.cs
index b35e3ae633bd..2abd922c1d86 100644
--- a/sdk/resourcemanager/Proto.Client/compute/AvailabilitySetOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/compute/AvailabilitySetOperations.cs
@@ -58,27 +58,27 @@ protected AvailabilitySetOperations(ResourceOperationsBase options, ResourceGrou
ClientOptions.Convert()).AvailabilitySets;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.Delete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return ArmResponse.FromResponse(Operations.Delete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse(await Operations.DeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return ArmResponse.FromResponse(await Operations.DeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.Delete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.Delete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.DeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.DeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/compute/RollingUpgradeOperations.cs b/sdk/resourcemanager/Proto.Client/compute/RollingUpgradeOperations.cs
index 8d6dbc2c239d..980921f3de9b 100644
--- a/sdk/resourcemanager/Proto.Client/compute/RollingUpgradeOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/compute/RollingUpgradeOperations.cs
@@ -60,16 +60,16 @@ await Operations.GetLatestAsync(ParentId.ResourceGroupName, ParentId.Name, cance
// Note: Singleton may have different operations such as GET/PUT/PATCH/POST or a combination of these
// Individual methods will be generated as they are declared
- public ArmResponse Cancel(CancellationToken cancellationToken = default)
+ public ArmResponse Cancel(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations
+ return ArmResponse.FromResponse(Operations
.StartCancel(ParentId.ResourceGroupName, ParentId.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
- public async Task> CancelAsync(CancellationToken cancellationToken = default)
+ public async Task CancelAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations
+ return ArmResponse.FromResponse((await Operations
.StartCancel(ParentId.ResourceGroupName, ParentId.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken)));
}
diff --git a/sdk/resourcemanager/Proto.Client/compute/VirtualMachineOperations.cs b/sdk/resourcemanager/Proto.Client/compute/VirtualMachineOperations.cs
index 5b5a04c8f6c8..9c6ffc18884c 100644
--- a/sdk/resourcemanager/Proto.Client/compute/VirtualMachineOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/compute/VirtualMachineOperations.cs
@@ -70,27 +70,27 @@ public static VirtualMachineOperations FromGeneric(GenericResourceOperations gen
}
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
#region PowerOn
@@ -98,42 +98,42 @@ public async Task> StartDeleteAsync(CancellationToken can
/// The operation to start a virtual machine.
///
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A response with the operation for this resource.
- public ArmResponse PowerOn(CancellationToken cancellationToken = default)
+ /// A response with the operation for this resource.
+ public ArmResponse PowerOn(CancellationToken cancellationToken = default)
{
var operation = Operations.StartStart(Id.ResourceGroupName, Id.Name, cancellationToken);
- return new ArmResponse(operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse(operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
/// The operation to start a virtual machine.
///
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A that on completion returns a response with the operation for this resource.
- public async Task> PowerOnAsync(CancellationToken cancellationToken = default)
+ /// A that on completion returns a response with the operation for this resource.
+ public async Task PowerOnAsync(CancellationToken cancellationToken = default)
{
var operation = await Operations.StartStartAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);
- return new ArmResponse(await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
+ return ArmResponse.FromResponse(await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
}
///
/// The operation to start a virtual machine.
///
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// An that allows polling for completion of the operation.
- public ArmOperation StartPowerOn(CancellationToken cancellationToken = default)
+ /// An that allows polling for completion of the operation.
+ public ArmOperation StartPowerOn(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartStart(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartStart(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
/// The operation to start a virtual machine.
///
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A that on completion returns an that allows polling for completion of the operation.
- public async Task> StartPowerOnAsync(CancellationToken cancellationToken = default)
+ /// A that on completion returns an that allows polling for completion of the operation.
+ public async Task StartPowerOnAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartStartAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false));
+ return new PhVoidArmOperation(await Operations.StartStartAsync(Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false));
}
#endregion
@@ -143,11 +143,11 @@ public async Task> StartPowerOnAsync(CancellationToken ca
///
/// The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified.
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A response with the operation for this resource.
- public ArmResponse PowerOff(bool? skipShutdown = null, CancellationToken cancellationToken = default)
+ /// A response with the operation for this resource.
+ public ArmResponse PowerOff(bool? skipShutdown = null, CancellationToken cancellationToken = default)
{
var operation = Operations.StartPowerOff(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken);
- return new ArmResponse(operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse(operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
@@ -155,11 +155,11 @@ public ArmResponse PowerOff(bool? skipShutdown = null, CancellationTok
///
/// The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified.
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A that on completion returns a response with the operation for this resource.
- public async Task> PowerOffAsync(bool? skipShutdown = null, CancellationToken cancellationToken = default)
+ /// A that on completion returns a response with the operation for this resource.
+ public async Task PowerOffAsync(bool? skipShutdown = null, CancellationToken cancellationToken = default)
{
var operation = await Operations.StartPowerOffAsync(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken).ConfigureAwait(false);
- return new ArmResponse(await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
+ return ArmResponse.FromResponse(await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false));
}
///
@@ -167,10 +167,10 @@ public async Task> PowerOffAsync(bool? skipShutdown = null
///
/// The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified.
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// An that allows polling for completion of the operation.
- public ArmOperation StartPowerOff(bool? skipShutdown = null, CancellationToken cancellationToken = default)
+ /// An that allows polling for completion of the operation.
+ public ArmOperation StartPowerOff(bool? skipShutdown = null, CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartPowerOff(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartPowerOff(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken));
}
///
@@ -178,10 +178,10 @@ public ArmOperation StartPowerOff(bool? skipShutdown = null, Cancellat
///
/// The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified.
/// A token to allow the caller to cancel the call to the service. The default value is .
- /// A that on completion returns an that allows polling for completion of the operation.
- public async Task> StartPowerOffAsync(bool? skipShutdown = null, CancellationToken cancellationToken = default)
+ /// A that on completion returns an that allows polling for completion of the operation.
+ public async Task StartPowerOffAsync(bool? skipShutdown = null, CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartPowerOffAsync(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken).ConfigureAwait(false));
+ return new PhVoidArmOperation(await Operations.StartPowerOffAsync(Id.ResourceGroupName, Id.Name, skipShutdown, cancellationToken).ConfigureAwait(false));
}
#endregion
diff --git a/sdk/resourcemanager/Proto.Client/compute/VirtualMachineScaleSetOperations.cs b/sdk/resourcemanager/Proto.Client/compute/VirtualMachineScaleSetOperations.cs
index d7425a1130c0..dae66829ac4d 100644
--- a/sdk/resourcemanager/Proto.Client/compute/VirtualMachineScaleSetOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/compute/VirtualMachineScaleSetOperations.cs
@@ -70,27 +70,27 @@ public static VirtualMachineScaleSetOperations FromGeneric(GenericResourceOperat
}
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/LoadBalancerOperations.cs b/sdk/resourcemanager/Proto.Client/network/LoadBalancerOperations.cs
index 2994fa8f1e50..4f42ffe004a7 100644
--- a/sdk/resourcemanager/Proto.Client/network/LoadBalancerOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/LoadBalancerOperations.cs
@@ -49,30 +49,30 @@ protected LoadBalancerOperations(ResourceOperationsBase options, ResourceIdentif
ClientOptions.Convert()).LoadBalancers;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/NetworkInterfaceOperations.cs b/sdk/resourcemanager/Proto.Client/network/NetworkInterfaceOperations.cs
index 60ffdb798789..6e022831b687 100644
--- a/sdk/resourcemanager/Proto.Client/network/NetworkInterfaceOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/NetworkInterfaceOperations.cs
@@ -49,29 +49,29 @@ protected NetworkInterfaceOperations(ResourceOperationsBase options, ResourceGro
ClientOptions.Convert()).NetworkInterfaces;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs
index 1a31336eca35..1571ad5e961d 100644
--- a/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/NetworkSecurityGroupOperations.cs
@@ -166,29 +166,29 @@ await Operations.UpdateTagsAsync(Id.ResourceGroupName, Id.Name, patchable, cance
}
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/PublicIpAddressOperations.cs b/sdk/resourcemanager/Proto.Client/network/PublicIpAddressOperations.cs
index 0e8c4d87f2d8..4b6a342409df 100644
--- a/sdk/resourcemanager/Proto.Client/network/PublicIpAddressOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/PublicIpAddressOperations.cs
@@ -61,29 +61,29 @@ protected PublicIpAddressOperations(ResourceOperationsBase options, ResourceIden
ClientOptions.Convert()).PublicIPAddresses;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken))
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/SubnetOperations.cs b/sdk/resourcemanager/Proto.Client/network/SubnetOperations.cs
index 5ab4f9bd5372..8e7a2478e9b9 100644
--- a/sdk/resourcemanager/Proto.Client/network/SubnetOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/SubnetOperations.cs
@@ -48,30 +48,30 @@ protected SubnetOperations(ResourceOperationsBase options, ResourceIdentifier id
ClientOptions.Convert()).Subnets;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken)
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken)
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken))
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken))
.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken));
}
///
diff --git a/sdk/resourcemanager/Proto.Client/network/VirtualNetworkOperations.cs b/sdk/resourcemanager/Proto.Client/network/VirtualNetworkOperations.cs
index 6a7db8239d72..a8d82492b9ca 100644
--- a/sdk/resourcemanager/Proto.Client/network/VirtualNetworkOperations.cs
+++ b/sdk/resourcemanager/Proto.Client/network/VirtualNetworkOperations.cs
@@ -60,27 +60,27 @@ protected VirtualNetworkOperations(ResourceOperationsBase options, ResourceIdent
ClientOptions.Convert()).VirtualNetworks;
///
- public ArmResponse Delete(CancellationToken cancellationToken = default)
+ public ArmResponse Delete(CancellationToken cancellationToken = default)
{
- return new ArmResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public async Task> DeleteAsync(CancellationToken cancellationToken = default)
+ public async Task DeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
+ return ArmResponse.FromResponse((await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken)).WaitForCompletionAsync(cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult());
}
///
- public ArmOperation StartDelete(CancellationToken cancellationToken = default)
+ public ArmOperation StartDelete(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(Operations.StartDelete(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///
- public async Task> StartDeleteAsync(CancellationToken cancellationToken = default)
+ public async Task StartDeleteAsync(CancellationToken cancellationToken = default)
{
- return new ArmVoidOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
+ return new PhVoidArmOperation(await Operations.StartDeleteAsync(Id.ResourceGroupName, Id.Name, cancellationToken));
}
///