@autorest/powershell 4.0.0-dev.8 → 4.0.617
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/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/package-deps_build.json +106 -103
- package/.rush/temp/shrinkwrap-deps.json +182 -234
- package/dist/cmdlets/class.d.ts +12 -1
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +693 -532
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +38 -5
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/enums/namespace.js +5 -5
- package/dist/enums/namespace.js.map +1 -1
- package/dist/generators/psm1.custom.js +2 -2
- package/dist/generators/psm1.custom.js.map +1 -1
- package/dist/generators/psm1.internal.js +2 -2
- package/dist/generators/psm1.internal.js.map +1 -1
- package/dist/generators/psm1.js +1 -1
- package/dist/generators/psm1.js.map +1 -1
- package/dist/generators/script-cmdlet.js +18 -18
- package/dist/generators/script-cmdlet.js.map +1 -1
- package/dist/internal/name-inferrer.d.ts +1 -1
- package/dist/internal/name-inferrer.d.ts.map +1 -1
- package/dist/internal/name-inferrer.js +12 -12
- package/dist/internal/name-inferrer.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +2 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +4 -2
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +3 -5
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +14 -18
- package/dist/internal/project.js.map +1 -1
- package/dist/internal/state.d.ts +1 -1
- package/dist/internal/state.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +1 -0
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +12 -11
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +7 -7
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/enums/enum.d.ts +1 -1
- package/dist/llcsharp/enums/enum.d.ts.map +1 -1
- package/dist/llcsharp/enums/enum.js +42 -42
- package/dist/llcsharp/enums/enum.js.map +1 -1
- package/dist/llcsharp/exports.js +5 -1
- package/dist/llcsharp/exports.js.map +1 -1
- package/dist/llcsharp/generator.d.ts +1 -1
- package/dist/llcsharp/generator.d.ts.map +1 -1
- package/dist/llcsharp/model/idictionary.js +16 -16
- package/dist/llcsharp/model/idictionary.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts +1 -1
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js +25 -11
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class-dictionary.js +18 -18
- package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
- package/dist/llcsharp/model/model-class-json.js +19 -19
- package/dist/llcsharp/model/model-class-json.js.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.d.ts +1 -1
- package/dist/llcsharp/model/model-class-serializer.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.js +6 -6
- package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
- package/dist/llcsharp/model/model-class.d.ts +1 -1
- package/dist/llcsharp/model/model-class.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class.js +97 -89
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/model/namespace.d.ts +1 -1
- package/dist/llcsharp/model/namespace.d.ts.map +1 -1
- package/dist/llcsharp/model/namespace.js +4 -12
- package/dist/llcsharp/model/namespace.js.map +1 -1
- package/dist/llcsharp/model/property.d.ts +1 -1
- package/dist/llcsharp/model/property.d.ts.map +1 -1
- package/dist/llcsharp/model/property.js +20 -20
- package/dist/llcsharp/model/property.js.map +1 -1
- package/dist/llcsharp/operation/api-class.d.ts.map +1 -1
- package/dist/llcsharp/operation/api-class.js +26 -1
- package/dist/llcsharp/operation/api-class.js.map +1 -1
- package/dist/llcsharp/operation/method.d.ts +10 -5
- package/dist/llcsharp/operation/method.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +276 -134
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/operation/parameter.d.ts +1 -1
- package/dist/llcsharp/operation/parameter.d.ts.map +1 -1
- package/dist/llcsharp/operation/parameter.js +10 -10
- package/dist/llcsharp/operation/parameter.js.map +1 -1
- package/dist/llcsharp/project.d.ts +4 -2
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +11 -3
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/Uuid.d.ts +1 -1
- package/dist/llcsharp/schema/Uuid.d.ts.map +1 -1
- package/dist/llcsharp/schema/Uuid.js +2 -2
- package/dist/llcsharp/schema/Uuid.js.map +1 -1
- package/dist/llcsharp/schema/array.d.ts +1 -1
- package/dist/llcsharp/schema/array.d.ts.map +1 -1
- package/dist/llcsharp/schema/array.js +45 -43
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/binary.d.ts +1 -1
- package/dist/llcsharp/schema/binary.d.ts.map +1 -1
- package/dist/llcsharp/schema/binary.js +9 -9
- package/dist/llcsharp/schema/binary.js.map +1 -1
- package/dist/llcsharp/schema/boolean.d.ts +1 -1
- package/dist/llcsharp/schema/boolean.d.ts.map +1 -1
- package/dist/llcsharp/schema/byte-array.d.ts +1 -1
- package/dist/llcsharp/schema/byte-array.d.ts.map +1 -1
- package/dist/llcsharp/schema/byte-array.js +24 -24
- package/dist/llcsharp/schema/byte-array.js.map +1 -1
- package/dist/llcsharp/schema/char.d.ts +1 -1
- package/dist/llcsharp/schema/char.d.ts.map +1 -1
- package/dist/llcsharp/schema/char.js +1 -1
- package/dist/llcsharp/schema/char.js.map +1 -1
- package/dist/llcsharp/schema/date-time.d.ts +1 -1
- package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
- package/dist/llcsharp/schema/date-time.js +45 -41
- package/dist/llcsharp/schema/date-time.js.map +1 -1
- package/dist/llcsharp/schema/date.d.ts +1 -1
- package/dist/llcsharp/schema/date.d.ts.map +1 -1
- package/dist/llcsharp/schema/duration.d.ts +1 -1
- package/dist/llcsharp/schema/duration.d.ts.map +1 -1
- package/dist/llcsharp/schema/duration.js +9 -7
- package/dist/llcsharp/schema/duration.js.map +1 -1
- package/dist/llcsharp/schema/enum.d.ts +6 -2
- package/dist/llcsharp/schema/enum.d.ts.map +1 -1
- package/dist/llcsharp/schema/enum.js +13 -4
- package/dist/llcsharp/schema/enum.js.map +1 -1
- package/dist/llcsharp/schema/extended-type-declaration.d.ts +1 -1
- package/dist/llcsharp/schema/extended-type-declaration.d.ts.map +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -1
- package/dist/llcsharp/schema/fixed-array.js +44 -42
- package/dist/llcsharp/schema/fixed-array.js.map +1 -1
- package/dist/llcsharp/schema/integer.d.ts +1 -1
- package/dist/llcsharp/schema/integer.d.ts.map +1 -1
- package/dist/llcsharp/schema/integer.js +5 -5
- package/dist/llcsharp/schema/integer.js.map +1 -1
- package/dist/llcsharp/schema/object.d.ts +1 -1
- package/dist/llcsharp/schema/object.d.ts.map +1 -1
- package/dist/llcsharp/schema/object.js +28 -28
- package/dist/llcsharp/schema/object.js.map +1 -1
- package/dist/llcsharp/schema/password.d.ts +1 -1
- package/dist/llcsharp/schema/password.d.ts.map +1 -1
- package/dist/llcsharp/schema/password.js +13 -13
- package/dist/llcsharp/schema/password.js.map +1 -1
- package/dist/llcsharp/schema/primitive.d.ts +1 -1
- package/dist/llcsharp/schema/primitive.d.ts.map +1 -1
- package/dist/llcsharp/schema/primitive.js +40 -37
- package/dist/llcsharp/schema/primitive.js.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.js +4 -9
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/llcsharp/schema/string.d.ts +1 -1
- package/dist/llcsharp/schema/string.d.ts.map +1 -1
- package/dist/llcsharp/schema/string.js +48 -44
- package/dist/llcsharp/schema/string.js.map +1 -1
- package/dist/llcsharp/schema/uri.d.ts +1 -1
- package/dist/llcsharp/schema/uri.d.ts.map +1 -1
- package/dist/llcsharp/schema/uri.js +2 -2
- package/dist/llcsharp/schema/uri.js.map +1 -1
- package/dist/llcsharp/validations.js +2 -2
- package/dist/llcsharp/validations.js.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/models/model-extensions.d.ts +1 -1
- package/dist/models/model-extensions.d.ts.map +1 -1
- package/dist/models/model-extensions.js +39 -39
- package/dist/models/model-extensions.js.map +1 -1
- package/dist/module/module-class.js +8 -8
- package/dist/module/module-class.js.map +1 -1
- package/dist/module/module-namespace.js +3 -3
- package/dist/module/module-namespace.js.map +1 -1
- package/dist/plugins/add-azure-completers-v2.d.ts +1 -1
- package/dist/plugins/add-azure-completers-v2.d.ts.map +1 -1
- package/dist/plugins/add-azure-completers-v2.js +3 -3
- package/dist/plugins/add-azure-completers-v2.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts +9 -7
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js +233 -62
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.d.ts +1 -1
- package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
- package/dist/plugins/cs-namer-v2.js +40 -40
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/llcsharp-v2.d.ts +1 -1
- package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
- package/dist/plugins/llcsharp-v2.js +12 -7
- package/dist/plugins/llcsharp-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts +1 -1
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +109 -78
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +42 -31
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.d.ts +1 -1
- package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +19 -7
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.d.ts +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.js +17 -17
- package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-model.d.ts +1 -1
- package/dist/plugins/plugin-tweak-model.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-model.js +31 -31
- package/dist/plugins/plugin-tweak-model.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +26 -26
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/ps-namer-v2.d.ts +1 -1
- package/dist/plugins/ps-namer-v2.d.ts.map +1 -1
- package/dist/plugins/ps-namer-v2.js +31 -31
- package/dist/plugins/ps-namer-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.js +37 -37
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
- package/dist/plugins/sdk-cs-namer.d.ts +1 -1
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-namer.js +21 -21
- package/dist/plugins/sdk-cs-namer.js.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.js +3 -3
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -1
- package/dist/plugins/sdk-generate.d.ts +1 -1
- package/dist/plugins/sdk-generate.d.ts.map +1 -1
- package/dist/plugins/sdk-generate.js +14 -14
- package/dist/plugins/sdk-generate.js.map +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
- package/dist/plugins/sdk-tweak-model.js +23 -23
- package/dist/plugins/sdk-tweak-model.js.map +1 -1
- package/dist/sdk/project.d.ts +2 -2
- package/dist/sdk/project.d.ts.map +1 -1
- package/dist/sdk/project.js +8 -8
- package/dist/sdk/project.js.map +1 -1
- package/dist/sdk/state.d.ts +2 -2
- package/dist/sdk/state.d.ts.map +1 -1
- package/dist/sdk/utility.d.ts +1 -1
- package/dist/sdk/utility.d.ts.map +1 -1
- package/dist/sdk/utility.js +17 -16
- package/dist/sdk/utility.js.map +1 -1
- package/dist/utils/PwshModel.d.ts +1 -1
- package/dist/utils/PwshModel.d.ts.map +1 -1
- package/dist/utils/PwshModel.js +1 -1
- package/dist/utils/PwshModel.js.map +1 -1
- package/dist/utils/SdkModel.d.ts +1 -1
- package/dist/utils/SdkModel.d.ts.map +1 -1
- package/dist/utils/SdkModel.js +1 -1
- package/dist/utils/SdkModel.js.map +1 -1
- package/dist/utils/command-operation.d.ts +9 -3
- package/dist/utils/command-operation.d.ts.map +1 -1
- package/dist/utils/command-operation.js +24 -4
- package/dist/utils/command-operation.js.map +1 -1
- package/dist/utils/components.d.ts +1 -1
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +2 -2
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/http-operation.d.ts +2 -0
- package/dist/utils/http-operation.d.ts.map +1 -1
- package/dist/utils/http-operation.js +16 -12
- package/dist/utils/http-operation.js.map +1 -1
- package/dist/utils/model-state.d.ts +1 -1
- package/dist/utils/model-state.d.ts.map +1 -1
- package/dist/utils/model-state.js +20 -20
- package/dist/utils/model-state.js.map +1 -1
- package/dist/utils/programatic-operation.d.ts +1 -1
- package/dist/utils/programatic-operation.d.ts.map +1 -1
- package/dist/utils/programatic-operation.js +1 -1
- package/dist/utils/programatic-operation.js.map +1 -1
- package/dist/utils/resolve-conflicts.js +8 -8
- package/dist/utils/resolve-conflicts.js.map +1 -1
- package/dist/utils/resourceName.d.ts +3 -0
- package/dist/utils/resourceName.d.ts.map +1 -0
- package/dist/utils/resourceName.js +29 -0
- package/dist/utils/resourceName.js.map +1 -0
- package/dist/utils/schema.d.ts +1 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +11 -11
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/security-scheme.d.ts +2 -2
- package/dist/utils/security-scheme.d.ts.map +1 -1
- package/dist/utils/security-scheme.js +2 -2
- package/dist/utils/security-scheme.js.map +1 -1
- package/dist/utils/sort-parameters.d.ts +3 -0
- package/dist/utils/sort-parameters.d.ts.map +1 -0
- package/dist/utils/sort-parameters.js +33 -0
- package/dist/utils/sort-parameters.js.map +1 -0
- package/package.json +7 -7
- package/resources/assets/build-module.ps1 +9 -4
- package/resources/assets/check-dependencies.ps1 +3 -3
- package/resources/assets/create-model-cmdlets.ps1 +33 -5
- package/resources/assets/export-surface.ps1 +3 -3
- package/resources/assets/generate-help.ps1 +5 -5
- package/resources/assets/generate-portal-ux.ps1 +3 -3
- package/resources/assets/run-module.ps1 +4 -4
- package/resources/assets/test-module.ps1 +5 -5
- package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
- package/resources/psruntime/Attributes/PSArgumentCompleterAttribute.cs +52 -0
- package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +4 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +6 -4
- package/resources/psruntime/BuildTime/MarkdownRenderer.cs +16 -8
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +20 -3
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +28 -2
- package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
- package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
- package/resources/psruntime/MessageAttribute.cs +23 -52
- package/resources/psruntime/MessageAttributeHelper.cs +5 -1
- package/resources/psruntime/Properties/Resources.Designer.cs +15 -2
- package/resources/psruntime/Properties/Resources.resx +4 -1
- package/resources/runtime/csharp/pipeline/ISendAsync.cs +113 -0
- package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
|
@@ -101,12 +101,23 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
101
101
|
if (String.IsNullOrEmpty(defaultParameterSet))
|
|
102
102
|
{
|
|
103
103
|
var variantParamCountGroups = Variants
|
|
104
|
+
.Where(v => !v.IsNotSuggestDefaultParameterSet)
|
|
104
105
|
.Select(v => (
|
|
105
106
|
variant: v.VariantName,
|
|
106
107
|
paramCount: v.CmdletOnlyParameters.Count(p => p.IsMandatory),
|
|
107
108
|
isSimple: v.CmdletOnlyParameters.Where(p => p.IsMandatory).All(p => p.ParameterType.IsPsSimple())))
|
|
108
109
|
.GroupBy(vpc => vpc.isSimple)
|
|
109
110
|
.ToArray();
|
|
111
|
+
if (variantParamCountGroups.Length == 0)
|
|
112
|
+
{
|
|
113
|
+
variantParamCountGroups = Variants
|
|
114
|
+
.Select(v => (
|
|
115
|
+
variant: v.VariantName,
|
|
116
|
+
paramCount: v.CmdletOnlyParameters.Count(p => p.IsMandatory),
|
|
117
|
+
isSimple: v.CmdletOnlyParameters.Where(p => p.IsMandatory).All(p => p.ParameterType.IsPsSimple())))
|
|
118
|
+
.GroupBy(vpc => vpc.isSimple)
|
|
119
|
+
.ToArray();
|
|
120
|
+
}
|
|
110
121
|
var variantParameterCounts = (variantParamCountGroups.Any(g => g.Key) ? variantParamCountGroups.Where(g => g.Key) : variantParamCountGroups).SelectMany(g => g).ToArray();
|
|
111
122
|
var smallestParameterCount = variantParameterCounts.Min(vpc => vpc.paramCount);
|
|
112
123
|
defaultParameterSet = variantParameterCounts.First(vpc => vpc.paramCount == smallestParameterCount).variant;
|
|
@@ -135,6 +146,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
135
146
|
public Parameter[] CmdletOnlyParameters { get; }
|
|
136
147
|
public bool IsInternal { get; }
|
|
137
148
|
public bool IsDoNotExport { get; }
|
|
149
|
+
public bool IsNotSuggestDefaultParameterSet { get; }
|
|
138
150
|
public string[] Profiles { get; }
|
|
139
151
|
|
|
140
152
|
public Variant(string cmdletName, string variantName, CommandInfo info, CommandMetadata metadata, bool hasParameterSets = false, PsHelpInfo helpInfo = null)
|
|
@@ -155,6 +167,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
155
167
|
Parameters = this.ToParameters().OrderBy(p => p.OrderCategory).ThenByDescending(p => p.IsMandatory).ToArray();
|
|
156
168
|
IsInternal = Attributes.OfType<InternalExportAttribute>().Any();
|
|
157
169
|
IsDoNotExport = Attributes.OfType<DoNotExportAttribute>().Any();
|
|
170
|
+
IsNotSuggestDefaultParameterSet = Attributes.OfType<NotSuggestDefaultParameterSetAttribute>().Any();
|
|
158
171
|
CmdletOnlyParameters = Parameters.Where(p => !p.Categories.Any(c => c == ParameterCategory.Azure || c == ParameterCategory.Runtime)).ToArray();
|
|
159
172
|
Profiles = Attributes.OfType<ProfileAttribute>().SelectMany(pa => pa.Profiles).ToArray();
|
|
160
173
|
}
|
|
@@ -210,6 +223,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
210
223
|
HasValidateNotNull = Parameters.SelectMany(p => p.Attributes.OfType<ValidateNotNullAttribute>()).Any();
|
|
211
224
|
HasAllowEmptyArray = Parameters.SelectMany(p => p.Attributes.OfType<AllowEmptyCollectionAttribute>()).Any();
|
|
212
225
|
CompleterInfo = Parameters.Select(p => p.CompleterInfoAttribute).FirstOrDefault()?.ToCompleterInfo()
|
|
226
|
+
?? Parameters.Select(p => p.PSArgumentCompleterAttribute).FirstOrDefault()?.ToPSArgumentCompleterInfo()
|
|
213
227
|
?? Parameters.Select(p => p.ArgumentCompleterAttribute).FirstOrDefault()?.ToCompleterInfo();
|
|
214
228
|
DefaultInfo = Parameters.Select(p => p.DefaultInfoAttribute).FirstOrDefault()?.ToDefaultInfo(this)
|
|
215
229
|
?? Parameters.Select(p => p.DefaultValueAttribute).FirstOrDefault(dv => dv != null)?.ToDefaultInfo(this);
|
|
@@ -254,6 +268,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
254
268
|
public bool SupportsWildcards { get; }
|
|
255
269
|
public CompleterInfoAttribute CompleterInfoAttribute { get; }
|
|
256
270
|
public ArgumentCompleterAttribute ArgumentCompleterAttribute { get; }
|
|
271
|
+
public PSArgumentCompleterAttribute PSArgumentCompleterAttribute { get; }
|
|
257
272
|
|
|
258
273
|
public bool ValueFromPipeline { get; }
|
|
259
274
|
public bool ValueFromPipelineByPropertyName { get; }
|
|
@@ -286,7 +301,8 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
286
301
|
}
|
|
287
302
|
SupportsWildcards = Attributes.OfType<SupportsWildcardsAttribute>().Any();
|
|
288
303
|
CompleterInfoAttribute = Attributes.OfType<CompleterInfoAttribute>().FirstOrDefault();
|
|
289
|
-
|
|
304
|
+
PSArgumentCompleterAttribute = Attributes.OfType<PSArgumentCompleterAttribute>().FirstOrDefault();
|
|
305
|
+
ArgumentCompleterAttribute = Attributes.OfType<ArgumentCompleterAttribute>().FirstOrDefault(attr => !attr.GetType().Equals(typeof(PSArgumentCompleterAttribute)));
|
|
290
306
|
|
|
291
307
|
ValueFromPipeline = ParameterAttribute.ValueFromPipeline;
|
|
292
308
|
ValueFromPipelineByPropertyName = ParameterAttribute.ValueFromPipelineByPropertyName;
|
|
@@ -424,6 +440,16 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
424
440
|
}
|
|
425
441
|
}
|
|
426
442
|
|
|
443
|
+
internal class PSArgumentCompleterInfo: CompleterInfo
|
|
444
|
+
{
|
|
445
|
+
public string[] ResourceTypes { get; }
|
|
446
|
+
|
|
447
|
+
public PSArgumentCompleterInfo(PSArgumentCompleterAttribute completerAttribute) : base(completerAttribute)
|
|
448
|
+
{
|
|
449
|
+
ResourceTypes = completerAttribute.ResourceTypes;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
427
453
|
internal class DefaultInfo
|
|
428
454
|
{
|
|
429
455
|
public string Name { get; }
|
|
@@ -513,7 +539,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
513
539
|
|
|
514
540
|
public static CompleterInfo ToCompleterInfo(this CompleterInfoAttribute infoAttribute) => new CompleterInfo(infoAttribute);
|
|
515
541
|
public static CompleterInfo ToCompleterInfo(this ArgumentCompleterAttribute completerAttribute) => new CompleterInfo(completerAttribute);
|
|
516
|
-
|
|
542
|
+
public static PSArgumentCompleterInfo ToPSArgumentCompleterInfo(this PSArgumentCompleterAttribute completerAttribute) => new PSArgumentCompleterInfo(completerAttribute);
|
|
517
543
|
public static DefaultInfo ToDefaultInfo(this DefaultInfoAttribute infoAttribute, ParameterGroup parameterGroup) => new DefaultInfo(infoAttribute, parameterGroup);
|
|
518
544
|
public static DefaultInfo ToDefaultInfo(this PSDefaultValueAttribute defaultValueAttribute, ParameterGroup parameterGroup) => new DefaultInfo(defaultValueAttribute, parameterGroup);
|
|
519
545
|
}
|
|
@@ -55,6 +55,11 @@ namespace Microsoft.Rest
|
|
|
55
55
|
public string ApiVersion { get; set; }
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
[AttributeUsage(AttributeTargets.Class)]
|
|
59
|
+
public class NotSuggestDefaultParameterSetAttribute : Attribute
|
|
60
|
+
{
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
59
64
|
public class CategoryAttribute : Attribute
|
|
60
65
|
{
|
|
@@ -39,9 +39,10 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
39
39
|
public static IEnumerable<FunctionInfo> GetScriptCmdlets(PSCmdlet cmdlet, string scriptFolder)
|
|
40
40
|
{
|
|
41
41
|
// https://stackoverflow.com/a/40969712/294804
|
|
42
|
+
var wrappedFolder = scriptFolder.Contains("'") ? $@"""{scriptFolder}""" : $@"'{scriptFolder}'";
|
|
42
43
|
var getCmdletsCommand = $@"
|
|
43
44
|
$currentFunctions = Get-ChildItem function:
|
|
44
|
-
Get-ChildItem -Path
|
|
45
|
+
Get-ChildItem -Path {wrappedFolder} -Recurse -Include '*.ps1' -File | ForEach-Object {{ . $_.FullName }}
|
|
45
46
|
Get-ChildItem function: | Where-Object {{ ($currentFunctions -notcontains $_) -and $_.CmdletBinding }}
|
|
46
47
|
";
|
|
47
48
|
return cmdlet?.RunScript<FunctionInfo>(getCmdletsCommand) ?? RunScript<FunctionInfo>(getCmdletsCommand);
|
|
@@ -66,7 +67,7 @@ Get-ChildItem function: | Where-Object {{ ($currentFunctions -notcontains $_) -a
|
|
|
66
67
|
|
|
67
68
|
public static IEnumerable<CmdletAndHelpInfo> GetModuleCmdletsAndHelpInfo(PSCmdlet cmdlet, params string[] modulePaths)
|
|
68
69
|
{
|
|
69
|
-
var getCmdletAndHelp = String.Join(" + ", modulePaths.Select(mp =>
|
|
70
|
+
var getCmdletAndHelp = String.Join(" + ", modulePaths.Select(mp =>
|
|
70
71
|
$@"(Get-Command -Module (Import-Module '{mp}' -PassThru) | Where-Object {{ $_.CommandType -ne 'Alias' }} | ForEach-Object {{ @{{ CommandInfo = $_; HelpInfo = ( invoke-command {{ try {{ Get-Help -Name $_.Name -Full }} catch{{ '' }} }} ) }} }})"
|
|
71
72
|
));
|
|
72
73
|
return (cmdlet?.RunScript<Hashtable>(getCmdletAndHelp) ?? RunScript<Hashtable>(getCmdletAndHelp))
|
|
@@ -87,7 +88,7 @@ Get-ChildItem function: | Where-Object {{ ($currentFunctions -notcontains $_) -a
|
|
|
87
88
|
if (File.Exists(psd1Path))
|
|
88
89
|
{
|
|
89
90
|
var currentGuid = File.ReadAllLines(psd1Path)
|
|
90
|
-
.FirstOrDefault(l => l.StartsWith(GuidStart))?.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries)
|
|
91
|
+
.FirstOrDefault(l => l.TrimStart().StartsWith(GuidStart.TrimStart()))?.Split(new[] { " = " }, StringSplitOptions.RemoveEmptyEntries)
|
|
91
92
|
.LastOrDefault()?.Replace("'", String.Empty);
|
|
92
93
|
guid = currentGuid != null ? Guid.Parse(currentGuid) : guid;
|
|
93
94
|
}
|
|
@@ -21,7 +21,7 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
21
21
|
|
|
22
22
|
//The version the change is effective from, non mandatory
|
|
23
23
|
public string DeprecateByVersion { get; }
|
|
24
|
-
public
|
|
24
|
+
public string DeprecateByAzVersion { get; }
|
|
25
25
|
|
|
26
26
|
//The date on which the change comes in effect
|
|
27
27
|
public DateTime ChangeInEfectByDate { get; }
|
|
@@ -32,23 +32,18 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
32
32
|
//New way fo calling the cmdlet
|
|
33
33
|
public string NewWay { get; set; }
|
|
34
34
|
|
|
35
|
-
public GenericBreakingChangeAttribute(string message)
|
|
36
|
-
{
|
|
37
|
-
_message = message;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public GenericBreakingChangeAttribute(string message, string deprecateByVersion)
|
|
35
|
+
public GenericBreakingChangeAttribute(string message, string deprecateByAzVersion, string deprecateByVersion)
|
|
41
36
|
{
|
|
42
37
|
_message = message;
|
|
38
|
+
this.DeprecateByAzVersion = deprecateByAzVersion;
|
|
43
39
|
this.DeprecateByVersion = deprecateByVersion;
|
|
44
|
-
this.DeprecateByVersionSet = true;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
public GenericBreakingChangeAttribute(string message, string deprecateByVersion, string changeInEfectByDate)
|
|
42
|
+
public GenericBreakingChangeAttribute(string message, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate)
|
|
48
43
|
{
|
|
49
44
|
_message = message;
|
|
50
45
|
this.DeprecateByVersion = deprecateByVersion;
|
|
51
|
-
this.
|
|
46
|
+
this.DeprecateByAzVersion = deprecateByAzVersion;
|
|
52
47
|
|
|
53
48
|
if (DateTime.TryParse(changeInEfectByDate, new CultureInfo("en-US"), DateTimeStyles.None, out DateTime result))
|
|
54
49
|
{
|
|
@@ -86,10 +81,8 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
86
81
|
writeOutput(string.Format(Resources.BreakingChangesAttributesInEffectByDateMessage, this.ChangeInEfectByDate.ToString("d")));
|
|
87
82
|
}
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
writeOutput(string.Format(Resources.BreakingChangesAttributesInEffectByVersion, this.DeprecateByVersion));
|
|
92
|
-
}
|
|
84
|
+
writeOutput(string.Format(Resources.BreakingChangesAttributesInEffectByAzVersion, this.DeprecateByAzVersion));
|
|
85
|
+
writeOutput(string.Format(Resources.BreakingChangesAttributesInEffectByVersion, this.DeprecateByVersion));
|
|
93
86
|
|
|
94
87
|
if (OldWay != null && NewWay != null)
|
|
95
88
|
{
|
|
@@ -114,18 +107,13 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
114
107
|
|
|
115
108
|
public string ReplacementCmdletName { get; set; }
|
|
116
109
|
|
|
117
|
-
public CmdletBreakingChangeAttribute() :
|
|
118
|
-
|
|
110
|
+
public CmdletBreakingChangeAttribute(string deprecateByAzVersion, string deprecateByVersion) :
|
|
111
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion)
|
|
119
112
|
{
|
|
120
113
|
}
|
|
121
114
|
|
|
122
|
-
public CmdletBreakingChangeAttribute(string
|
|
123
|
-
base(string.Empty,
|
|
124
|
-
{
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public CmdletBreakingChangeAttribute(string deprecateByVersion, string changeInEfectByDate) :
|
|
128
|
-
base(string.Empty, deprecateByVersion, changeInEfectByDate)
|
|
115
|
+
public CmdletBreakingChangeAttribute(string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate) :
|
|
116
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEfectByDate)
|
|
129
117
|
{
|
|
130
118
|
}
|
|
131
119
|
|
|
@@ -146,20 +134,15 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
146
134
|
public class ParameterSetBreakingChangeAttribute : GenericBreakingChangeAttribute
|
|
147
135
|
{
|
|
148
136
|
public string[] ChangedParameterSet { set; get; }
|
|
149
|
-
public ParameterSetBreakingChangeAttribute(string[] changedParameterSet) :
|
|
150
|
-
base(string.Empty)
|
|
151
|
-
{
|
|
152
|
-
ChangedParameterSet = changedParameterSet;
|
|
153
|
-
}
|
|
154
137
|
|
|
155
|
-
public ParameterSetBreakingChangeAttribute(string[] changedParameterSet, string
|
|
156
|
-
base(string.Empty,
|
|
138
|
+
public ParameterSetBreakingChangeAttribute(string[] changedParameterSet, string deprecateByAzVersion, string deprecateByVersion) :
|
|
139
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion)
|
|
157
140
|
{
|
|
158
141
|
ChangedParameterSet = changedParameterSet;
|
|
159
142
|
}
|
|
160
143
|
|
|
161
|
-
public ParameterSetBreakingChangeAttribute(string[] changedParameterSet, string deprecateByVersion, string changeInEfectByDate) :
|
|
162
|
-
base(string.Empty, deprecateByVersion, changeInEfectByDate)
|
|
144
|
+
public ParameterSetBreakingChangeAttribute(string[] changedParameterSet, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate) :
|
|
145
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEfectByDate)
|
|
163
146
|
{
|
|
164
147
|
ChangedParameterSet = changedParameterSet;
|
|
165
148
|
}
|
|
@@ -219,20 +202,14 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
219
202
|
|
|
220
203
|
public String NewParameterType { get; set; }
|
|
221
204
|
|
|
222
|
-
public ParameterBreakingChangeAttribute(string nameOfParameterChanging) :
|
|
223
|
-
|
|
224
|
-
{
|
|
225
|
-
this.NameOfParameterChanging = nameOfParameterChanging;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public ParameterBreakingChangeAttribute(string nameOfParameterChanging, string deprecateByVersion) :
|
|
229
|
-
base(string.Empty, deprecateByVersion)
|
|
205
|
+
public ParameterBreakingChangeAttribute(string nameOfParameterChanging, string deprecateByAzVersion, string deprecateByVersion) :
|
|
206
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion)
|
|
230
207
|
{
|
|
231
208
|
this.NameOfParameterChanging = nameOfParameterChanging;
|
|
232
209
|
}
|
|
233
210
|
|
|
234
|
-
public ParameterBreakingChangeAttribute(string nameOfParameterChanging, string deprecateByVersion, string changeInEfectByDate) :
|
|
235
|
-
base(string.Empty, deprecateByVersion, changeInEfectByDate)
|
|
211
|
+
public ParameterBreakingChangeAttribute(string nameOfParameterChanging, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate) :
|
|
212
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEfectByDate)
|
|
236
213
|
{
|
|
237
214
|
this.NameOfParameterChanging = nameOfParameterChanging;
|
|
238
215
|
}
|
|
@@ -298,20 +275,14 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
298
275
|
|
|
299
276
|
public string[] NewOutputProperties { get; set; }
|
|
300
277
|
|
|
301
|
-
public OutputBreakingChangeAttribute(string deprecatedCmdletOutputType) :
|
|
302
|
-
|
|
303
|
-
{
|
|
304
|
-
this.DeprecatedCmdLetOutputType = deprecatedCmdletOutputType;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public OutputBreakingChangeAttribute(string deprecatedCmdletOutputType, string deprecateByVersion) :
|
|
308
|
-
base(string.Empty, deprecateByVersion)
|
|
278
|
+
public OutputBreakingChangeAttribute(string deprecatedCmdletOutputType, string deprecateByAzVersion, string deprecateByVersion) :
|
|
279
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion)
|
|
309
280
|
{
|
|
310
281
|
this.DeprecatedCmdLetOutputType = deprecatedCmdletOutputType;
|
|
311
282
|
}
|
|
312
283
|
|
|
313
|
-
public OutputBreakingChangeAttribute(string deprecatedCmdletOutputType, string deprecateByVersion, string changeInEfectByDate) :
|
|
314
|
-
base(string.Empty, deprecateByVersion, changeInEfectByDate)
|
|
284
|
+
public OutputBreakingChangeAttribute(string deprecatedCmdletOutputType, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate) :
|
|
285
|
+
base(string.Empty, deprecateByAzVersion, deprecateByVersion, changeInEfectByDate)
|
|
315
286
|
{
|
|
316
287
|
this.DeprecatedCmdLetOutputType = deprecatedCmdletOutputType;
|
|
317
288
|
}
|
|
@@ -23,6 +23,7 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
23
23
|
using System.Threading.Tasks;
|
|
24
24
|
public class MessageAttributeHelper
|
|
25
25
|
{
|
|
26
|
+
private static readonly bool IsAzure = Convert.ToBoolean(@"${$project.azure}");
|
|
26
27
|
public const string BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK = "https://aka.ms/azps-changewarnings";
|
|
27
28
|
public const string SUPPRESS_ERROR_OR_WARNING_MESSAGE_ENV_VARIABLE_NAME = "SuppressAzurePowerShellBreakingChangeWarnings";
|
|
28
29
|
|
|
@@ -52,7 +53,10 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
52
53
|
//Do not process the attributes at runtime... The env variable to override the warning messages is set
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
if (IsAzure && invocationInfo.BoundParameters.ContainsKey("DefaultProfile"))
|
|
57
|
+
{
|
|
58
|
+
psCmdlet.WriteWarning("The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.");
|
|
59
|
+
}
|
|
56
60
|
List<GenericBreakingChangeAttribute> attributes = new List<GenericBreakingChangeAttribute>(GetAllBreakingChangeAttributesInType(commandInfo, invocationInfo, parameterSet));
|
|
57
61
|
StringBuilder sb = new StringBuilder();
|
|
58
62
|
Action<string> appendBreakingChangeInfo = (string s) => sb.Append(s);
|
|
@@ -734,7 +734,7 @@ namespace Microsoft.generated.runtime.Properties
|
|
|
734
734
|
}
|
|
735
735
|
|
|
736
736
|
/// <summary>
|
|
737
|
-
/// Looks up a localized string similar to Note :The change is expected to take effect from
|
|
737
|
+
/// Looks up a localized string similar to Note :The change is expected to take effect from version : '{0}'
|
|
738
738
|
///
|
|
739
739
|
///.
|
|
740
740
|
/// </summary>
|
|
@@ -746,6 +746,19 @@ namespace Microsoft.generated.runtime.Properties
|
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
+
/// <summary>
|
|
750
|
+
/// Looks up a localized string similar to Note :The change is expected to take effect from az version : '{0}'
|
|
751
|
+
///
|
|
752
|
+
///.
|
|
753
|
+
/// </summary>
|
|
754
|
+
public static string BreakingChangesAttributesInEffectByAzVersion
|
|
755
|
+
{
|
|
756
|
+
get
|
|
757
|
+
{
|
|
758
|
+
return ResourceManager.GetString("BreakingChangesAttributesInEffectByAzVersion", resourceCulture);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
749
762
|
/// <summary>
|
|
750
763
|
/// Looks up a localized string similar to ```powershell
|
|
751
764
|
///# Old
|
|
@@ -5630,4 +5643,4 @@ namespace Microsoft.generated.runtime.Properties
|
|
|
5630
5643
|
}
|
|
5631
5644
|
}
|
|
5632
5645
|
}
|
|
5633
|
-
}
|
|
5646
|
+
}
|
|
@@ -1705,7 +1705,7 @@ Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can
|
|
|
1705
1705
|
</data>
|
|
1706
1706
|
<data name="BreakingChangesAttributesInEffectByVersion" xml:space="preserve">
|
|
1707
1707
|
<value>
|
|
1708
|
-
- The change is expected to take effect from
|
|
1708
|
+
- The change is expected to take effect from version : '{0}'</value>
|
|
1709
1709
|
</data>
|
|
1710
1710
|
<data name="BreakingChangesAttributesUsageChangeMessage" xml:space="preserve">
|
|
1711
1711
|
<value>```powershell
|
|
@@ -1738,4 +1738,7 @@ Note : Go to {0} for steps to suppress this breaking change warning, and other i
|
|
|
1738
1738
|
<data name="PreviewCmdletMessage" xml:space="preserve">
|
|
1739
1739
|
<value>This cmdlet is in preview. The functionality may not be available in the selected subscription.</value>
|
|
1740
1740
|
</data>
|
|
1741
|
+
<data name="BreakingChangesAttributesInEffectByAzVersion" xml:space="preserve">
|
|
1742
|
+
<value>- The change is expected to take effect from Az version : '{0}'</value>
|
|
1743
|
+
</data>
|
|
1741
1744
|
</root>
|
|
@@ -11,6 +11,8 @@ namespace Microsoft.Rest.ClientRuntime
|
|
|
11
11
|
using System.Threading.Tasks;
|
|
12
12
|
using System.Collections;
|
|
13
13
|
using System.Linq;
|
|
14
|
+
using System;
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
/// <summary>
|
|
16
18
|
/// The interface for sending an HTTP request across the wire.
|
|
@@ -70,6 +72,7 @@ namespace Microsoft.Rest.ClientRuntime
|
|
|
70
72
|
|
|
71
73
|
public partial class HttpPipeline : ISendAsync
|
|
72
74
|
{
|
|
75
|
+
private const int DefaultMaxRetry = 3;
|
|
73
76
|
private ISendAsync pipeline;
|
|
74
77
|
private ISendAsyncTerminalFactory terminal;
|
|
75
78
|
private List<ISendAsyncFactory> steps = new List<ISendAsyncFactory>();
|
|
@@ -92,6 +95,111 @@ namespace Microsoft.Rest.ClientRuntime
|
|
|
92
95
|
/// </summary>
|
|
93
96
|
public HttpPipeline Clone() => new HttpPipeline(terminal) { steps = this.steps.ToList(), pipeline = this.pipeline };
|
|
94
97
|
|
|
98
|
+
private bool shouldRetry429(HttpResponseMessage response)
|
|
99
|
+
{
|
|
100
|
+
if (response.StatusCode == (System.Net.HttpStatusCode)429)
|
|
101
|
+
{
|
|
102
|
+
var retryAfter = response.Headers.RetryAfter;
|
|
103
|
+
if (retryAfter != null && retryAfter.Delta.HasValue)
|
|
104
|
+
{
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/// <summary>
|
|
111
|
+
/// The step to handle 429 response with retry-after header.
|
|
112
|
+
/// </summary>
|
|
113
|
+
public async Task<HttpResponseMessage> Retry429(HttpRequestMessage request, IEventListener callback, ISendAsync next)
|
|
114
|
+
{
|
|
115
|
+
int retryCount = int.MaxValue;
|
|
116
|
+
|
|
117
|
+
try
|
|
118
|
+
{
|
|
119
|
+
try
|
|
120
|
+
{
|
|
121
|
+
retryCount = int.Parse(System.Environment.GetEnvironmentVariable("PS_HTTP_MAX_RETRIES_FOR_429"));
|
|
122
|
+
}
|
|
123
|
+
finally
|
|
124
|
+
{
|
|
125
|
+
retryCount = int.Parse(System.Environment.GetEnvironmentVariable("AZURE_PS_HTTP_MAX_RETRIES_FOR_429"));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (System.Exception)
|
|
129
|
+
{
|
|
130
|
+
//no action
|
|
131
|
+
}
|
|
132
|
+
var cloneRequest = await request.CloneWithContent();
|
|
133
|
+
var response = await next.SendAsync(request, callback);
|
|
134
|
+
int count = 0;
|
|
135
|
+
while (shouldRetry429(response) && count++ < retryCount)
|
|
136
|
+
{
|
|
137
|
+
request = await cloneRequest.CloneWithContent();
|
|
138
|
+
var retryAfter = response.Headers.RetryAfter;
|
|
139
|
+
await Task.Delay(retryAfter.Delta.Value, callback.Token);
|
|
140
|
+
await callback.Signal("Debug", $"Start to retry {count} time(s) on status code 429 after waiting {retryAfter.Delta.Value.TotalSeconds} seconds.");
|
|
141
|
+
response = await next.SendAsync(request, callback);
|
|
142
|
+
}
|
|
143
|
+
return response;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private bool shouldRetryError(HttpResponseMessage response)
|
|
147
|
+
{
|
|
148
|
+
if (response.StatusCode >= System.Net.HttpStatusCode.InternalServerError)
|
|
149
|
+
{
|
|
150
|
+
if (response.StatusCode != System.Net.HttpStatusCode.NotImplemented &&
|
|
151
|
+
response.StatusCode != System.Net.HttpStatusCode.HttpVersionNotSupported)
|
|
152
|
+
{
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (response.StatusCode == System.Net.HttpStatusCode.RequestTimeout)
|
|
157
|
+
{
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
else if (response.StatusCode == (System.Net.HttpStatusCode)429 && response.Headers.RetryAfter == null)
|
|
161
|
+
{
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// <summary>
|
|
168
|
+
/// Returns true if status code in HttpRequestExceptionWithStatus exception is greater
|
|
169
|
+
/// than or equal to 500 and not NotImplemented (501) or HttpVersionNotSupported (505).
|
|
170
|
+
/// Or it's 429 (TOO MANY REQUESTS) without Retry-After header.
|
|
171
|
+
/// </summary>
|
|
172
|
+
public async Task<HttpResponseMessage> RetryError(HttpRequestMessage request, IEventListener callback, ISendAsync next)
|
|
173
|
+
{
|
|
174
|
+
int retryCount = DefaultMaxRetry;
|
|
175
|
+
|
|
176
|
+
try
|
|
177
|
+
{
|
|
178
|
+
try
|
|
179
|
+
{
|
|
180
|
+
retryCount = int.Parse(System.Environment.GetEnvironmentVariable("PS_HTTP_MAX_RETRIES"));
|
|
181
|
+
}
|
|
182
|
+
finally
|
|
183
|
+
{
|
|
184
|
+
retryCount = int.Parse(System.Environment.GetEnvironmentVariable("AZURE_PS_HTTP_MAX_RETRIES"));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (System.Exception)
|
|
188
|
+
{
|
|
189
|
+
//no action
|
|
190
|
+
}
|
|
191
|
+
var cloneRequest = await request.CloneWithContent();
|
|
192
|
+
var response = await next.SendAsync(request, callback);
|
|
193
|
+
int count = 0;
|
|
194
|
+
while (shouldRetryError(response) && count++ < retryCount)
|
|
195
|
+
{
|
|
196
|
+
await callback.Signal("Debug", $"Start to retry {count} time(s) on status code {response.StatusCode}");
|
|
197
|
+
request = await cloneRequest.CloneWithContent();
|
|
198
|
+
response = await next.SendAsync(request, callback);
|
|
199
|
+
}
|
|
200
|
+
return response;
|
|
201
|
+
}
|
|
202
|
+
|
|
95
203
|
public ISendAsyncTerminalFactory TerminalFactory
|
|
96
204
|
{
|
|
97
205
|
get => terminal;
|
|
@@ -117,6 +225,11 @@ namespace Microsoft.Rest.ClientRuntime
|
|
|
117
225
|
|
|
118
226
|
// create the pipeline from scratch.
|
|
119
227
|
var next = terminal.Create();
|
|
228
|
+
if (Convert.ToBoolean(@"${$project.enableApiRetry}"))
|
|
229
|
+
{
|
|
230
|
+
next = (new SendAsyncFactory(Retry429)).Create(next) ?? next;
|
|
231
|
+
next = (new SendAsyncFactory(RetryError)).Create(next) ?? next;
|
|
232
|
+
}
|
|
120
233
|
foreach (var factory in steps)
|
|
121
234
|
{
|
|
122
235
|
// skip factories that return null.
|