@autorest/powershell 4.0.0-dev.7 → 4.0.0-dev.9
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/package-deps_build.json +58 -54
- package/autorest-configuration.md +1 -1
- package/dist/cmdlets/class.d.ts +7 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +248 -81
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +1 -0
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/generators/psm1.js +1 -1
- package/dist/generators/script-cmdlet.js +1 -1
- package/dist/internal/powershell-declarations.d.ts +1 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +2 -1
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +9 -4
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +7 -9
- package/dist/internal/project.js.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 +1 -0
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/csharp-declarations.d.ts +1 -0
- package/dist/llcsharp/csharp-declarations.d.ts.map +1 -1
- package/dist/llcsharp/csharp-declarations.js +2 -1
- package/dist/llcsharp/csharp-declarations.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js +14 -0
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class.js +27 -11
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/model/namespace.d.ts.map +1 -1
- package/dist/llcsharp/model/namespace.js +3 -11
- package/dist/llcsharp/model/namespace.js.map +1 -1
- package/dist/llcsharp/project.d.ts +2 -1
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +5 -3
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/array.js +7 -7
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts +42 -0
- package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -0
- package/dist/llcsharp/schema/fixed-array.js +251 -0
- package/dist/llcsharp/schema/fixed-array.js.map +1 -0
- 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 +12 -10
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts +1 -0
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js +39 -6
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
- package/dist/plugins/cs-namer-v2.js +10 -7
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
- package/dist/plugins/llcsharp-v2.js +4 -1
- package/dist/plugins/llcsharp-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +21 -2
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +12 -0
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.js +26 -0
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-namer.js +17 -9
- package/dist/plugins/sdk-cs-namer.js.map +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
- package/dist/plugins/sdk-tweak-model.js +13 -5
- package/dist/plugins/sdk-tweak-model.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/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 +1 -1
- package/resources/assets/build-module.ps1 +4 -4
- package/resources/assets/check-dependencies.ps1 +3 -3
- package/resources/assets/create-model-cmdlets.ps1 +84 -15
- package/resources/assets/custom/README.md +1 -1
- package/resources/assets/docs/README.md +1 -1
- package/resources/assets/export-surface.ps1 +3 -3
- package/resources/assets/exports/README.md +1 -1
- package/resources/assets/generate-help.ps1 +3 -3
- package/resources/assets/generate-portal-ux.ps1 +3 -3
- package/resources/assets/how-to.md +1 -1
- package/resources/assets/internal/README.md +1 -1
- package/resources/assets/run-module.ps1 +4 -4
- package/resources/assets/test-module.ps1 +6 -6
- package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +1 -1
- package/resources/assets/tools/Resources/docs/README.md +1 -1
- package/resources/assets/tools/Resources/how-to.md +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.nuspec +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +34 -34
- package/resources/modules/Az.Accounts/2.7.5/en-US/about_az.help.txt +1 -1
- package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +1 -1
- package/resources/psruntime/Attributes/PSArgumentCompleterAttribute.cs +52 -0
- package/resources/psruntime/BuildTime/Cmdlets/ExportFormatPs1xml.cs +3 -1
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +18 -1
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +15 -2
- package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
- package/resources/psruntime/BuildTime/PsExtensions.cs +7 -0
- package/resources/psruntime/TypeConverterExtensions.cs +50 -0
- package/resources/runtime/csharp/json/Nodes/Collections/XNodeArray.cs +5 -0
- package/resources/runtime/csharp/pipeline/ISendAsync.cs +113 -0
- package/resources/templates/methodBodyRestCall.ejs +1 -1
|
@@ -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.
|
|
@@ -52,7 +52,7 @@ if (method.extensions && method.extensions['x-ms-request-id']) {
|
|
|
52
52
|
<%# ToDo: add support for BuildInputMappings -%>
|
|
53
53
|
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
|
|
54
54
|
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten']) {-%>
|
|
55
|
-
<%-
|
|
55
|
+
<%-parameter.schema.language.default.name%> <%-parameter.language.default.name%> = new <%-parameter.schema.language.default.name%>();
|
|
56
56
|
<% var vps = project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties)-%>
|
|
57
57
|
if(<%-vps.map(vp=>`${vp.property.language.default.name} != null`).join('||')%>)
|
|
58
58
|
{
|