@azure-typespec/http-client-csharp-mgmt 1.0.0-alpha.20250409.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/emitter/emitter.d.ts.map +1 -0
- package/dist/emitter/emitter.js +77 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/emitter/index.d.ts +2 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +4 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/emitter/resource-type.d.ts +2 -0
- package/dist/emitter/resource-type.d.ts.map +1 -0
- package/dist/emitter/resource-type.js +31 -0
- package/dist/emitter/resource-type.js.map +1 -0
- package/dist/emitter/sdk-context-options.d.ts +3 -0
- package/dist/emitter/sdk-context-options.d.ts.map +1 -0
- package/dist/emitter/sdk-context-options.js +23 -0
- package/dist/emitter/sdk-context-options.js.map +1 -0
- package/dist/generator/Azure.Core.dll +0 -0
- package/dist/generator/Azure.Generator.Mgmt.deps.json +998 -0
- package/dist/generator/Azure.Generator.Mgmt.dll +0 -0
- package/dist/generator/Azure.Generator.Mgmt.pdb +0 -0
- package/dist/generator/Azure.Generator.Mgmt.xml +818 -0
- package/dist/generator/Azure.Generator.dll +0 -0
- package/dist/generator/Azure.Generator.pdb +0 -0
- package/dist/generator/Azure.Generator.xml +163 -0
- package/dist/generator/Azure.ResourceManager.dll +0 -0
- package/dist/generator/CommandLine.dll +0 -0
- package/dist/generator/Humanizer.dll +0 -0
- package/dist/generator/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/dist/generator/Microsoft.Build.Framework.dll +0 -0
- package/dist/generator/Microsoft.Build.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/dist/generator/Microsoft.CodeAnalysis.dll +0 -0
- package/dist/generator/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- package/dist/generator/Microsoft.NET.StringTools.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.Input.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.dll +0 -0
- package/dist/generator/Microsoft.TypeSpec.Generator.runtimeconfig.json +12 -0
- package/dist/generator/NuGet.Common.dll +0 -0
- package/dist/generator/NuGet.Configuration.dll +0 -0
- package/dist/generator/NuGet.Frameworks.dll +0 -0
- package/dist/generator/Shared/Core/AppContextSwitchHelper.cs +42 -0
- package/dist/generator/Shared/Core/AsyncLockWithValue.cs +260 -0
- package/dist/generator/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
- package/dist/generator/Shared/Core/ClientDiagnostics.cs +73 -0
- package/dist/generator/Shared/Core/DiagnosticScope.cs +473 -0
- package/dist/generator/Shared/Core/DiagnosticScopeFactory.cs +104 -0
- package/dist/generator/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
- package/dist/generator/Shared/Core/HttpMessageSanitizer.cs +198 -0
- package/dist/generator/Shared/Core/IOperationSource.cs +14 -0
- package/dist/generator/Shared/Core/NextLinkOperationImplementation.cs +690 -0
- package/dist/generator/Shared/Core/OperationFinalStateVia.cs +16 -0
- package/dist/generator/Shared/Core/OperationInternal.cs +256 -0
- package/dist/generator/Shared/Core/OperationInternalBase.cs +234 -0
- package/dist/generator/Shared/Core/OperationInternalOfT.cs +422 -0
- package/dist/generator/Shared/Core/OperationPoller.cs +114 -0
- package/dist/generator/Shared/Core/RawRequestUriBuilder.cs +192 -0
- package/dist/generator/Shared/Core/SequentialDelayStrategy.cs +38 -0
- package/dist/generator/Shared/Core/TaskExtensions.cs +313 -0
- package/dist/generator/Shared/Core/VoidValue.cs +10 -0
- package/dist/generator/System.ClientModel.dll +0 -0
- package/dist/generator/System.ComponentModel.Composition.dll +0 -0
- package/dist/generator/System.Composition.AttributedModel.dll +0 -0
- package/dist/generator/System.Composition.Convention.dll +0 -0
- package/dist/generator/System.Composition.Hosting.dll +0 -0
- package/dist/generator/System.Composition.Runtime.dll +0 -0
- package/dist/generator/System.Composition.TypedParts.dll +0 -0
- package/dist/generator/System.Configuration.ConfigurationManager.dll +0 -0
- package/dist/generator/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/System.IO.Pipelines.dll +0 -0
- package/dist/generator/System.Memory.Data.dll +0 -0
- package/dist/generator/System.Reflection.MetadataLoadContext.dll +0 -0
- package/dist/generator/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/Azure.Core.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.deps.json +998 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.pdb +0 -0
- package/dist/generator/net8.0/Azure.Generator.Mgmt.xml +818 -0
- package/dist/generator/net8.0/Azure.Generator.dll +0 -0
- package/dist/generator/net8.0/Azure.Generator.pdb +0 -0
- package/dist/generator/net8.0/Azure.Generator.xml +163 -0
- package/dist/generator/net8.0/Azure.ResourceManager.dll +0 -0
- package/dist/generator/net8.0/CommandLine.dll +0 -0
- package/dist/generator/net8.0/Humanizer.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Build.Framework.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Build.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/dist/generator/net8.0/Microsoft.CodeAnalysis.dll +0 -0
- package/dist/generator/net8.0/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- package/dist/generator/net8.0/Microsoft.NET.StringTools.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.Input.dll +0 -0
- package/dist/generator/net8.0/Microsoft.TypeSpec.Generator.dll +0 -0
- package/dist/generator/net8.0/NuGet.Common.dll +0 -0
- package/dist/generator/net8.0/NuGet.Configuration.dll +0 -0
- package/dist/generator/net8.0/NuGet.Frameworks.dll +0 -0
- package/dist/generator/net8.0/Shared/Core/AppContextSwitchHelper.cs +42 -0
- package/dist/generator/net8.0/Shared/Core/AsyncLockWithValue.cs +260 -0
- package/dist/generator/net8.0/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
- package/dist/generator/net8.0/Shared/Core/ClientDiagnostics.cs +73 -0
- package/dist/generator/net8.0/Shared/Core/DiagnosticScope.cs +473 -0
- package/dist/generator/net8.0/Shared/Core/DiagnosticScopeFactory.cs +104 -0
- package/dist/generator/net8.0/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
- package/dist/generator/net8.0/Shared/Core/HttpMessageSanitizer.cs +198 -0
- package/dist/generator/net8.0/Shared/Core/IOperationSource.cs +14 -0
- package/dist/generator/net8.0/Shared/Core/NextLinkOperationImplementation.cs +690 -0
- package/dist/generator/net8.0/Shared/Core/OperationFinalStateVia.cs +16 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternal.cs +256 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternalBase.cs +234 -0
- package/dist/generator/net8.0/Shared/Core/OperationInternalOfT.cs +422 -0
- package/dist/generator/net8.0/Shared/Core/OperationPoller.cs +114 -0
- package/dist/generator/net8.0/Shared/Core/RawRequestUriBuilder.cs +192 -0
- package/dist/generator/net8.0/Shared/Core/SequentialDelayStrategy.cs +38 -0
- package/dist/generator/net8.0/Shared/Core/TaskExtensions.cs +313 -0
- package/dist/generator/net8.0/Shared/Core/VoidValue.cs +10 -0
- package/dist/generator/net8.0/System.ClientModel.dll +0 -0
- package/dist/generator/net8.0/System.ComponentModel.Composition.dll +0 -0
- package/dist/generator/net8.0/System.Composition.AttributedModel.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Convention.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Hosting.dll +0 -0
- package/dist/generator/net8.0/System.Composition.Runtime.dll +0 -0
- package/dist/generator/net8.0/System.Composition.TypedParts.dll +0 -0
- package/dist/generator/net8.0/System.Configuration.ConfigurationManager.dll +0 -0
- package/dist/generator/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/net8.0/System.IO.Pipelines.dll +0 -0
- package/dist/generator/net8.0/System.Memory.Data.dll +0 -0
- package/dist/generator/net8.0/System.Reflection.MetadataLoadContext.dll +0 -0
- package/dist/generator/net8.0/System.Security.Cryptography.ProtectedData.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- package/dist/generator/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/net8.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
- package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/package.json +67 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#nullable enable
|
|
5
|
+
|
|
6
|
+
namespace Azure.Core
|
|
7
|
+
{
|
|
8
|
+
internal enum OperationFinalStateVia
|
|
9
|
+
{
|
|
10
|
+
AzureAsyncOperation,
|
|
11
|
+
Location,
|
|
12
|
+
OriginalUri,
|
|
13
|
+
OperationLocation,
|
|
14
|
+
LocationOverride,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Threading;
|
|
7
|
+
using System.Threading.Tasks;
|
|
8
|
+
using Azure.Core.Pipeline;
|
|
9
|
+
|
|
10
|
+
#nullable enable
|
|
11
|
+
|
|
12
|
+
namespace Azure.Core
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
/// A helper class used to build long-running operation instances. In order to use this helper:
|
|
16
|
+
/// <list type="number">
|
|
17
|
+
/// <item>Make sure your LRO implements the <see cref="IOperation"/> interface.</item>
|
|
18
|
+
/// <item>Add a private <see cref="OperationInternal"/> field to your LRO, and instantiate it during construction.</item>
|
|
19
|
+
/// <item>Delegate method calls to the <see cref="OperationInternal"/> implementations.</item>
|
|
20
|
+
/// </list>
|
|
21
|
+
/// Supported members:
|
|
22
|
+
/// <list type="bullet">
|
|
23
|
+
/// <item>
|
|
24
|
+
/// <description><see cref="OperationInternalBase.HasCompleted"/></description>
|
|
25
|
+
/// </item>
|
|
26
|
+
/// <item>
|
|
27
|
+
/// <description><see cref="OperationInternalBase.RawResponse"/>, used for <see cref="Operation.GetRawResponse"/></description>
|
|
28
|
+
/// </item>
|
|
29
|
+
/// <item>
|
|
30
|
+
/// <description><see cref="OperationInternalBase.UpdateStatus"/></description>
|
|
31
|
+
/// </item>
|
|
32
|
+
/// <item>
|
|
33
|
+
/// <description><see cref="OperationInternalBase.UpdateStatusAsync(CancellationToken)"/></description>
|
|
34
|
+
/// </item>
|
|
35
|
+
/// <item>
|
|
36
|
+
/// <description><see cref="OperationInternalBase.WaitForCompletionResponseAsync(CancellationToken)"/></description>
|
|
37
|
+
/// </item>
|
|
38
|
+
/// <item>
|
|
39
|
+
/// <description><see cref="OperationInternalBase.WaitForCompletionResponseAsync(TimeSpan, CancellationToken)"/></description>
|
|
40
|
+
/// </item>
|
|
41
|
+
/// </list>
|
|
42
|
+
/// </summary>
|
|
43
|
+
internal class OperationInternal : OperationInternalBase
|
|
44
|
+
{
|
|
45
|
+
// To minimize code duplication and avoid introduction of another type,
|
|
46
|
+
// OperationInternal delegates implementation to the OperationInternal<VoidValue>.
|
|
47
|
+
// VoidValue is a private empty struct which only purpose is to be used as generic parameter.
|
|
48
|
+
private readonly OperationInternal<VoidValue> _internalOperation;
|
|
49
|
+
|
|
50
|
+
/// <summary>
|
|
51
|
+
/// Initializes a new instance of the <see cref="OperationInternal"/> class in a final successful state.
|
|
52
|
+
/// </summary>
|
|
53
|
+
/// <param name="rawResponse">The final value of <see cref="OperationInternalBase.RawResponse"/>.</param>
|
|
54
|
+
public static OperationInternal Succeeded(Response rawResponse) => new(OperationState.Success(rawResponse));
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
/// Initializes a new instance of the <see cref="OperationInternal"/> class in a final failed state.
|
|
58
|
+
/// </summary>
|
|
59
|
+
/// <param name="rawResponse">The final value of <see cref="OperationInternalBase.RawResponse"/>.</param>
|
|
60
|
+
/// <param name="operationFailedException">The exception that will be thrown by <c>UpdateStatusAsync</c>.</param>
|
|
61
|
+
public static OperationInternal Failed(Response rawResponse, RequestFailedException operationFailedException) => new(OperationState.Failure(rawResponse, operationFailedException));
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Initializes a new instance of the <see cref="OperationInternal"/> class.
|
|
65
|
+
/// </summary>
|
|
66
|
+
/// <param name="operation">The long-running operation making use of this class. Passing "<c>this</c>" is expected.</param>
|
|
67
|
+
/// <param name="clientDiagnostics">Used for diagnostic scope and exception creation. This is expected to be the instance created during the construction of your main client.</param>
|
|
68
|
+
/// <param name="rawResponse">
|
|
69
|
+
/// The initial value of <see cref="OperationInternalBase.RawResponse"/>. Usually, long-running operation objects can be instantiated in two ways:
|
|
70
|
+
/// <list type="bullet">
|
|
71
|
+
/// <item>
|
|
72
|
+
/// When calling a client's "<c>Start<OperationName></c>" method, a service call is made to start the operation, and an <see cref="Operation"/> instance is returned.
|
|
73
|
+
/// In this case, the response received from this service call can be passed here.
|
|
74
|
+
/// </item>
|
|
75
|
+
/// <item>
|
|
76
|
+
/// When a user instantiates an <see cref="Operation"/> directly using a public constructor, there's no previous service call. In this case, passing <c>null</c> is expected.
|
|
77
|
+
/// </item>
|
|
78
|
+
/// </list>
|
|
79
|
+
/// </param>
|
|
80
|
+
/// <param name="operationTypeName">
|
|
81
|
+
/// The type name of the long-running operation making use of this class. Used when creating diagnostic scopes. If left <c>null</c>, the type name will be inferred based on the
|
|
82
|
+
/// parameter <paramref name="operation"/>.
|
|
83
|
+
/// </param>
|
|
84
|
+
/// <param name="scopeAttributes">The attributes to use during diagnostic scope creation.</param>
|
|
85
|
+
/// <param name="fallbackStrategy"> The delay strategy to use. Default is <see cref="FixedDelayWithNoJitterStrategy"/>.</param>
|
|
86
|
+
public OperationInternal(IOperation operation,
|
|
87
|
+
ClientDiagnostics clientDiagnostics,
|
|
88
|
+
Response rawResponse,
|
|
89
|
+
string? operationTypeName = null,
|
|
90
|
+
IEnumerable<KeyValuePair<string, string>>? scopeAttributes = null,
|
|
91
|
+
DelayStrategy? fallbackStrategy = null)
|
|
92
|
+
: base(clientDiagnostics, operationTypeName ?? operation.GetType().Name, scopeAttributes, fallbackStrategy)
|
|
93
|
+
{
|
|
94
|
+
_internalOperation = new OperationInternal<VoidValue>(new OperationToOperationOfTProxy(operation), clientDiagnostics, rawResponse, operationTypeName ?? operation.GetType().Name, scopeAttributes, fallbackStrategy);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
internal OperationInternal(OperationState finalState)
|
|
98
|
+
: base(finalState.RawResponse)
|
|
99
|
+
{
|
|
100
|
+
_internalOperation = finalState.HasSucceeded
|
|
101
|
+
? OperationInternal<VoidValue>.Succeeded(finalState.RawResponse, default)
|
|
102
|
+
: OperationInternal<VoidValue>.Failed(finalState.RawResponse, finalState.OperationFailedException!);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public override Response RawResponse => _internalOperation.RawResponse;
|
|
106
|
+
|
|
107
|
+
public override bool HasCompleted => _internalOperation.HasCompleted;
|
|
108
|
+
|
|
109
|
+
protected override async ValueTask<Response> UpdateStatusAsync(bool async, CancellationToken cancellationToken) =>
|
|
110
|
+
async ? await _internalOperation.UpdateStatusAsync(cancellationToken).ConfigureAwait(false) : _internalOperation.UpdateStatus(cancellationToken);
|
|
111
|
+
|
|
112
|
+
// Wrapper type that converts OperationState to OperationState<T> and can be passed to `OperationInternal<T>` constructor.
|
|
113
|
+
private class OperationToOperationOfTProxy : IOperation<VoidValue>
|
|
114
|
+
{
|
|
115
|
+
private readonly IOperation _operation;
|
|
116
|
+
|
|
117
|
+
public OperationToOperationOfTProxy(IOperation operation)
|
|
118
|
+
{
|
|
119
|
+
_operation = operation;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public async ValueTask<OperationState<VoidValue>> UpdateStateAsync(bool async, CancellationToken cancellationToken)
|
|
123
|
+
{
|
|
124
|
+
var state = await _operation.UpdateStateAsync(async, cancellationToken).ConfigureAwait(false);
|
|
125
|
+
if (!state.HasCompleted)
|
|
126
|
+
{
|
|
127
|
+
return OperationState<VoidValue>.Pending(state.RawResponse);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (state.HasSucceeded)
|
|
131
|
+
{
|
|
132
|
+
return OperationState<VoidValue>.Success(state.RawResponse, new VoidValue());
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return OperationState<VoidValue>.Failure(state.RawResponse, state.OperationFailedException);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// <summary>
|
|
141
|
+
/// An interface used by <see cref="OperationInternal"/> for making service calls and updating state. It's expected that
|
|
142
|
+
/// your long-running operation classes implement this interface.
|
|
143
|
+
/// </summary>
|
|
144
|
+
internal interface IOperation
|
|
145
|
+
{
|
|
146
|
+
/// <summary>
|
|
147
|
+
/// Calls the service and updates the state of the long-running operation. Properties directly handled by the
|
|
148
|
+
/// <see cref="OperationInternal"/> class, such as <see cref="OperationInternalBase.RawResponse"/>
|
|
149
|
+
/// don't need to be updated. Operation-specific properties, such as "<c>CreateOn</c>" or "<c>LastModified</c>",
|
|
150
|
+
/// must be manually updated by the operation implementing this method.
|
|
151
|
+
/// <example>Usage example:
|
|
152
|
+
/// <code>
|
|
153
|
+
/// async ValueTask<OperationState> IOperation.UpdateStateAsync(bool async, CancellationToken cancellationToken)<br/>
|
|
154
|
+
/// {<br/>
|
|
155
|
+
/// Response<R> response = async ? <async service call> : <sync service call>;<br/>
|
|
156
|
+
/// if (<operation succeeded>) return OperationState.Success(response.GetRawResponse(), <parse response>);<br/>
|
|
157
|
+
/// if (<operation failed>) return OperationState.Failure(response.GetRawResponse());<br/>
|
|
158
|
+
/// return OperationState.Pending(response.GetRawResponse());<br/>
|
|
159
|
+
/// }
|
|
160
|
+
/// </code>
|
|
161
|
+
/// </example>
|
|
162
|
+
/// </summary>
|
|
163
|
+
/// <param name="async"><c>true</c> if the call should be executed asynchronously. Otherwise, <c>false</c>.</param>
|
|
164
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
165
|
+
/// <returns>
|
|
166
|
+
/// A structure indicating the current operation state. The <see cref="OperationState"/> structure must be instantiated by one of
|
|
167
|
+
/// its static methods:
|
|
168
|
+
/// <list type="bullet">
|
|
169
|
+
/// <item>Use <see cref="OperationState.Success"/> when the operation has completed successfully.</item>
|
|
170
|
+
/// <item>Use <see cref="OperationState.Failure"/> when the operation has completed with failures.</item>
|
|
171
|
+
/// <item>Use <see cref="OperationState.Pending"/> when the operation has not completed yet.</item>
|
|
172
|
+
/// </list>
|
|
173
|
+
/// </returns>
|
|
174
|
+
ValueTask<OperationState> UpdateStateAsync(bool async, CancellationToken cancellationToken);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/// <summary>
|
|
178
|
+
/// A helper structure passed to <see cref="OperationInternal"/> to indicate the current operation state. This structure must be
|
|
179
|
+
/// instantiated by one of its static methods, depending on the operation state:
|
|
180
|
+
/// <list type="bullet">
|
|
181
|
+
/// <item>Use <see cref="OperationState.Success"/> when the operation has completed successfully.</item>
|
|
182
|
+
/// <item>Use <see cref="OperationState.Failure"/> when the operation has completed with failures.</item>
|
|
183
|
+
/// <item>Use <see cref="OperationState.Pending"/> when the operation has not completed yet.</item>
|
|
184
|
+
/// </list>
|
|
185
|
+
/// </summary>
|
|
186
|
+
internal readonly struct OperationState
|
|
187
|
+
{
|
|
188
|
+
private OperationState(Response rawResponse, bool hasCompleted, bool hasSucceeded, RequestFailedException? operationFailedException)
|
|
189
|
+
{
|
|
190
|
+
RawResponse = rawResponse;
|
|
191
|
+
HasCompleted = hasCompleted;
|
|
192
|
+
HasSucceeded = hasSucceeded;
|
|
193
|
+
OperationFailedException = operationFailedException;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public Response RawResponse { get; }
|
|
197
|
+
|
|
198
|
+
public bool HasCompleted { get; }
|
|
199
|
+
|
|
200
|
+
public bool HasSucceeded { get; }
|
|
201
|
+
|
|
202
|
+
public RequestFailedException? OperationFailedException { get; }
|
|
203
|
+
|
|
204
|
+
/// <summary>
|
|
205
|
+
/// Instantiates an <see cref="OperationState"/> indicating the operation has completed successfully.
|
|
206
|
+
/// </summary>
|
|
207
|
+
/// <param name="rawResponse">The HTTP response obtained during the status update.</param>
|
|
208
|
+
/// <returns>A new <see cref="OperationState"/> instance.</returns>
|
|
209
|
+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="rawResponse"/> is <c>null</c>.</exception>
|
|
210
|
+
public static OperationState Success(Response rawResponse)
|
|
211
|
+
{
|
|
212
|
+
if (rawResponse is null)
|
|
213
|
+
{
|
|
214
|
+
throw new ArgumentNullException(nameof(rawResponse));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return new OperationState(rawResponse, true, true, default);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// <summary>
|
|
221
|
+
/// Instantiates an <see cref="OperationState"/> indicating the operation has completed with failures.
|
|
222
|
+
/// </summary>
|
|
223
|
+
/// <param name="rawResponse">The HTTP response obtained during the status update.</param>
|
|
224
|
+
/// <param name="operationFailedException">
|
|
225
|
+
/// The exception to throw from <c>UpdateStatus</c> because of the operation failure. If left <c>null</c>,
|
|
226
|
+
/// a default exception is created based on the <paramref name="rawResponse"/> parameter.
|
|
227
|
+
/// </param>
|
|
228
|
+
/// <returns>A new <see cref="OperationState"/> instance.</returns>
|
|
229
|
+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="rawResponse"/> is <c>null</c>.</exception>
|
|
230
|
+
public static OperationState Failure(Response rawResponse, RequestFailedException? operationFailedException = null)
|
|
231
|
+
{
|
|
232
|
+
if (rawResponse is null)
|
|
233
|
+
{
|
|
234
|
+
throw new ArgumentNullException(nameof(rawResponse));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return new OperationState(rawResponse, true, false, operationFailedException);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// <summary>
|
|
241
|
+
/// Instantiates an <see cref="OperationState"/> indicating the operation has not completed yet.
|
|
242
|
+
/// </summary>
|
|
243
|
+
/// <param name="rawResponse">The HTTP response obtained during the status update.</param>
|
|
244
|
+
/// <returns>A new <see cref="OperationState"/> instance.</returns>
|
|
245
|
+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="rawResponse"/> is <c>null</c>.</exception>
|
|
246
|
+
public static OperationState Pending(Response rawResponse)
|
|
247
|
+
{
|
|
248
|
+
if (rawResponse is null)
|
|
249
|
+
{
|
|
250
|
+
throw new ArgumentNullException(nameof(rawResponse));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return new OperationState(rawResponse, false, default, default);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#nullable enable
|
|
5
|
+
|
|
6
|
+
using System;
|
|
7
|
+
using System.Collections.Generic;
|
|
8
|
+
using System.Linq;
|
|
9
|
+
using System.Threading;
|
|
10
|
+
using System.Threading.Tasks;
|
|
11
|
+
using Azure.Core.Pipeline;
|
|
12
|
+
|
|
13
|
+
namespace Azure.Core
|
|
14
|
+
{
|
|
15
|
+
internal abstract class OperationInternalBase
|
|
16
|
+
{
|
|
17
|
+
private readonly ClientDiagnostics _diagnostics;
|
|
18
|
+
private readonly IReadOnlyDictionary<string, string>? _scopeAttributes;
|
|
19
|
+
private readonly DelayStrategy? _fallbackStrategy;
|
|
20
|
+
private readonly AsyncLockWithValue<Response> _responseLock;
|
|
21
|
+
|
|
22
|
+
private readonly string _waitForCompletionResponseScopeName;
|
|
23
|
+
protected readonly string _updateStatusScopeName;
|
|
24
|
+
protected readonly string _waitForCompletionScopeName;
|
|
25
|
+
|
|
26
|
+
protected OperationInternalBase(Response rawResponse)
|
|
27
|
+
{
|
|
28
|
+
_diagnostics = new ClientDiagnostics(ClientOptions.Default);
|
|
29
|
+
_updateStatusScopeName = string.Empty;
|
|
30
|
+
_waitForCompletionResponseScopeName = string.Empty;
|
|
31
|
+
_waitForCompletionScopeName = string.Empty;
|
|
32
|
+
_scopeAttributes = default;
|
|
33
|
+
_fallbackStrategy = default;
|
|
34
|
+
_responseLock = new AsyncLockWithValue<Response>(rawResponse);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected OperationInternalBase(ClientDiagnostics clientDiagnostics, string operationTypeName, IEnumerable<KeyValuePair<string, string>>? scopeAttributes = null, DelayStrategy? fallbackStrategy = null)
|
|
38
|
+
{
|
|
39
|
+
_diagnostics = clientDiagnostics;
|
|
40
|
+
_updateStatusScopeName = $"{operationTypeName}.{nameof(UpdateStatus)}";
|
|
41
|
+
_waitForCompletionResponseScopeName = $"{operationTypeName}.{nameof(WaitForCompletionResponse)}";
|
|
42
|
+
_waitForCompletionScopeName = $"{operationTypeName}.WaitForCompletion";
|
|
43
|
+
_scopeAttributes = scopeAttributes?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
|
44
|
+
_fallbackStrategy = fallbackStrategy;
|
|
45
|
+
_responseLock = new AsyncLockWithValue<Response>();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// The last HTTP response received from the server. Its update already handled in calls to "<c>UpdateStatus</c>" and
|
|
50
|
+
/// "<c>WaitForCompletionAsync</c>", but custom methods not supported by this class, such as "<c>CancelOperation</c>",
|
|
51
|
+
/// must update it as well.
|
|
52
|
+
/// <example>Usage example:
|
|
53
|
+
/// <code>
|
|
54
|
+
/// public Response GetRawResponse() => _operationInternal.RawResponse;
|
|
55
|
+
/// </code>
|
|
56
|
+
/// </example>
|
|
57
|
+
/// </summary>
|
|
58
|
+
public abstract Response RawResponse { get; }
|
|
59
|
+
|
|
60
|
+
/// <summary>
|
|
61
|
+
/// Returns <c>true</c> if the long-running operation has completed.
|
|
62
|
+
/// <example>Usage example:
|
|
63
|
+
/// <code>
|
|
64
|
+
/// public bool HasCompleted => _operationInternal.HasCompleted;
|
|
65
|
+
/// </code>
|
|
66
|
+
/// </example>
|
|
67
|
+
/// </summary>
|
|
68
|
+
public abstract bool HasCompleted { get; }
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
/// Calls the server to get the latest status of the long-running operation, handling diagnostic scope creation for distributed
|
|
72
|
+
/// tracing. The default scope name can be changed with the "<c>operationTypeName</c>" parameter passed to the constructor.
|
|
73
|
+
/// <example>Usage example:
|
|
74
|
+
/// <code>
|
|
75
|
+
/// public async ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken) =>
|
|
76
|
+
/// await _operationInternal.UpdateStatusAsync(cancellationToken).ConfigureAwait(false);
|
|
77
|
+
/// </code>
|
|
78
|
+
/// </example>
|
|
79
|
+
/// </summary>
|
|
80
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
81
|
+
/// <returns>The HTTP response received from the server.</returns>
|
|
82
|
+
/// <remarks>
|
|
83
|
+
/// After a successful run, this method will update <see cref="RawResponse"/> and might update <see cref="HasCompleted"/>.
|
|
84
|
+
/// </remarks>
|
|
85
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
86
|
+
public async ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken) =>
|
|
87
|
+
await UpdateStatusAsync(async: true, cancellationToken).ConfigureAwait(false);
|
|
88
|
+
|
|
89
|
+
/// <summary>
|
|
90
|
+
/// Calls the server to get the latest status of the long-running operation, handling diagnostic scope creation for distributed
|
|
91
|
+
/// tracing. The default scope name can be changed with the "<c>operationTypeName</c>" parameter passed to the constructor.
|
|
92
|
+
/// <example>Usage example:
|
|
93
|
+
/// <code>
|
|
94
|
+
/// public Response UpdateStatus(CancellationToken cancellationToken) => _operationInternal.UpdateStatus(cancellationToken);
|
|
95
|
+
/// </code>
|
|
96
|
+
/// </example>
|
|
97
|
+
/// </summary>
|
|
98
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
99
|
+
/// <returns>The HTTP response received from the server.</returns>
|
|
100
|
+
/// <remarks>
|
|
101
|
+
/// After a successful run, this method will update <see cref="RawResponse"/> and might update <see cref="HasCompleted"/>.
|
|
102
|
+
/// </remarks>
|
|
103
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
104
|
+
public Response UpdateStatus(CancellationToken cancellationToken) =>
|
|
105
|
+
UpdateStatusAsync(async: false, cancellationToken).EnsureCompleted();
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
/// Periodically calls <see cref="UpdateStatusAsync(CancellationToken)"/> until the long-running operation completes.
|
|
109
|
+
/// After each service call, a retry-after header may be returned to communicate that there is no reason to poll
|
|
110
|
+
/// for status change until the specified time has passed. The maximum of the retry after value and the fallback strategy
|
|
111
|
+
/// is then used as the wait interval.
|
|
112
|
+
/// Headers supported are: "Retry-After", "retry-after-ms", and "x-ms-retry-after-ms",
|
|
113
|
+
/// <example>Usage example:
|
|
114
|
+
/// <code>
|
|
115
|
+
/// public async ValueTask<Response<T>> WaitForCompletionAsync(CancellationToken cancellationToken) =>
|
|
116
|
+
/// await _operationInternal.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
|
|
117
|
+
/// </code>
|
|
118
|
+
/// </example>
|
|
119
|
+
/// </summary>
|
|
120
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
121
|
+
/// <returns>The last HTTP response received from the server, including the final result of the long-running operation.</returns>
|
|
122
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
123
|
+
public async ValueTask<Response> WaitForCompletionResponseAsync(CancellationToken cancellationToken)
|
|
124
|
+
=> await WaitForCompletionResponseAsync(async: true, null, _waitForCompletionResponseScopeName, cancellationToken).ConfigureAwait(false);
|
|
125
|
+
|
|
126
|
+
/// <summary>
|
|
127
|
+
/// Periodically calls <see cref="UpdateStatusAsync(CancellationToken)"/> until the long-running operation completes. The interval
|
|
128
|
+
/// between calls is defined by the parameter <paramref name="pollingInterval"/>, but it can change based on information returned
|
|
129
|
+
/// from the server. After each service call, a retry-after header may be returned to communicate that there is no reason to poll
|
|
130
|
+
/// for status change until the specified time has passed. In this case, the maximum value between the <paramref name="pollingInterval"/>
|
|
131
|
+
/// parameter and the retry-after header is chosen as the wait interval. Headers supported are: "Retry-After", "retry-after-ms",
|
|
132
|
+
/// and "x-ms-retry-after-ms".
|
|
133
|
+
/// <example>Usage example:
|
|
134
|
+
/// <code>
|
|
135
|
+
/// public async ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) =>
|
|
136
|
+
/// await _operationInternal.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);
|
|
137
|
+
/// </code>
|
|
138
|
+
/// </example>
|
|
139
|
+
/// </summary>
|
|
140
|
+
/// <param name="pollingInterval">The interval between status requests to the server. <strong></strong></param>
|
|
141
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
142
|
+
/// <returns>The last HTTP response received from the server, including the final result of the long-running operation.</returns>
|
|
143
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
144
|
+
public async ValueTask<Response> WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken)
|
|
145
|
+
=> await WaitForCompletionResponseAsync(async: true, pollingInterval, _waitForCompletionResponseScopeName, cancellationToken).ConfigureAwait(false);
|
|
146
|
+
|
|
147
|
+
/// <summary>
|
|
148
|
+
/// Periodically calls <see cref="UpdateStatus(CancellationToken)"/> until the long-running operation completes.
|
|
149
|
+
/// After each service call, a retry-after header may be returned to communicate that there is no reason to poll
|
|
150
|
+
/// for status change until the specified time has passed. The maximum of the retry after value and the fallback strategy
|
|
151
|
+
/// is then used as the wait interval.
|
|
152
|
+
/// Headers supported are: "Retry-After", "retry-after-ms", and "x-ms-retry-after-ms",
|
|
153
|
+
/// and "x-ms-retry-after-ms".
|
|
154
|
+
/// <example>Usage example:
|
|
155
|
+
/// <code>
|
|
156
|
+
/// public async ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) =>
|
|
157
|
+
/// await _operationInternal.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);
|
|
158
|
+
/// </code>
|
|
159
|
+
/// </example>
|
|
160
|
+
/// </summary>
|
|
161
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
162
|
+
/// <returns>The last HTTP response received from the server, including the final result of the long-running operation.</returns>
|
|
163
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
164
|
+
public Response WaitForCompletionResponse(CancellationToken cancellationToken)
|
|
165
|
+
=> WaitForCompletionResponseAsync(async: false, null, _waitForCompletionResponseScopeName, cancellationToken).EnsureCompleted();
|
|
166
|
+
|
|
167
|
+
/// <summary>
|
|
168
|
+
/// Periodically calls <see cref="UpdateStatus(CancellationToken)"/> until the long-running operation completes. The interval
|
|
169
|
+
/// between calls is defined by the parameter <paramref name="pollingInterval"/>, but it can change based on information returned
|
|
170
|
+
/// from the server. After each service call, a retry-after header may be returned to communicate that there is no reason to poll
|
|
171
|
+
/// for status change until the specified time has passed. In this case, the maximum value between the <paramref name="pollingInterval"/>
|
|
172
|
+
/// parameter and the retry-after header is chosen as the wait interval. Headers supported are: "Retry-After", "retry-after-ms",
|
|
173
|
+
/// and "x-ms-retry-after-ms".
|
|
174
|
+
/// <example>Usage example:
|
|
175
|
+
/// <code>
|
|
176
|
+
/// public async ValueTask<Response<T>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken) =>
|
|
177
|
+
/// await _operationInternal.WaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);
|
|
178
|
+
/// </code>
|
|
179
|
+
/// </example>
|
|
180
|
+
/// </summary>
|
|
181
|
+
/// <param name="pollingInterval">The interval between status requests to the server.</param>
|
|
182
|
+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
|
|
183
|
+
/// <returns>The last HTTP response received from the server, including the final result of the long-running operation.</returns>
|
|
184
|
+
/// <exception cref="RequestFailedException">Thrown if there's been any issues during the connection, or if the operation has completed with failures.</exception>
|
|
185
|
+
public Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken)
|
|
186
|
+
=> WaitForCompletionResponseAsync(async: false, pollingInterval, _waitForCompletionResponseScopeName, cancellationToken).EnsureCompleted();
|
|
187
|
+
|
|
188
|
+
protected async ValueTask<Response> WaitForCompletionResponseAsync(bool async, TimeSpan? pollingInterval, string scopeName, CancellationToken cancellationToken)
|
|
189
|
+
{
|
|
190
|
+
// If _responseLock has the value, lockOrValue will contain that value, and no lock is acquired.
|
|
191
|
+
// If _responseLock doesn't have the value, GetLockOrValueAsync will acquire the lock that will be released when lockOrValue is disposed
|
|
192
|
+
using var lockOrValue = await _responseLock.GetLockOrValueAsync(async, cancellationToken).ConfigureAwait(false);
|
|
193
|
+
if (lockOrValue.HasValue)
|
|
194
|
+
{
|
|
195
|
+
return lockOrValue.Value;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
using var scope = CreateScope(scopeName);
|
|
199
|
+
try
|
|
200
|
+
{
|
|
201
|
+
var poller = new OperationPoller(_fallbackStrategy);
|
|
202
|
+
var response = async
|
|
203
|
+
? await poller.WaitForCompletionResponseAsync(this, pollingInterval, cancellationToken).ConfigureAwait(false)
|
|
204
|
+
: poller.WaitForCompletionResponse(this, pollingInterval, cancellationToken);
|
|
205
|
+
|
|
206
|
+
lockOrValue.SetValue(response);
|
|
207
|
+
return response;
|
|
208
|
+
}
|
|
209
|
+
catch (Exception e)
|
|
210
|
+
{
|
|
211
|
+
scope.Failed(e);
|
|
212
|
+
throw;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
protected abstract ValueTask<Response> UpdateStatusAsync(bool async, CancellationToken cancellationToken);
|
|
217
|
+
|
|
218
|
+
protected DiagnosticScope CreateScope(string scopeName)
|
|
219
|
+
{
|
|
220
|
+
DiagnosticScope scope = _diagnostics.CreateScope(scopeName);
|
|
221
|
+
|
|
222
|
+
if (_scopeAttributes != null)
|
|
223
|
+
{
|
|
224
|
+
foreach (KeyValuePair<string, string> attribute in _scopeAttributes)
|
|
225
|
+
{
|
|
226
|
+
scope.AddAttribute(attribute.Key, attribute.Value);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
scope.Start();
|
|
231
|
+
return scope;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|