@autorest/powershell 4.0.728 → 4.0.730

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.
@@ -77,7 +77,7 @@
77
77
  "powershell/models/model-extensions.ts": "2b3c129d070b0a30b01d32eb8998043c30b1bd7d",
78
78
  "powershell/module/module-class.ts": "ffef6105f5566125c72dc525dd33ed0ddd05b910",
79
79
  "powershell/module/module-namespace.ts": "f6afc90087e8d733f0323b0de8ba41d923955732",
80
- "powershell/package.json": "1a6489a4b26077ebee28bc472e92c6a32bda293e",
80
+ "powershell/package.json": "dc5adb5de6c41ce1c4b10813cc6ac43bf3ec50e7",
81
81
  "powershell/plugins/add-azure-completers-v2.ts": "46e91eb274a6a863315be8c0d5c9d84597654bce",
82
82
  "powershell/plugins/create-commands-v2.ts": "7fcf503415666f3bbfb22072f29a804b098413df",
83
83
  "powershell/plugins/cs-namer-v2.ts": "f16981643ae24355e937ea717e33508e46dd2da2",
@@ -98,7 +98,7 @@
98
98
  "powershell/readme.md": "eeb191589b240161a10502f6d21e35b23f9bc805",
99
99
  "powershell/resources/assets/build-module.ps1": "f4ddd8263f14cdb0bcbfb8c292e6ed8390b2a58c",
100
100
  "powershell/resources/assets/check-dependencies.ps1": "2b60454c4749ce45ebabb419e2228b0b80b89545",
101
- "powershell/resources/assets/create-model-cmdlets.ps1": "e36b0bc3af005c5de4bb61e4da3396be18bab11b",
101
+ "powershell/resources/assets/create-model-cmdlets.ps1": "e25d04e3c2d0d2da46c79f8d7dacd543b349c861",
102
102
  "powershell/resources/assets/custom/README.md": "8f35d9de2dd67e37c4135b2d91dc194b33c9cd3f",
103
103
  "powershell/resources/assets/docs/README.md": "7ea7065e913f5792b57d826f5cf12c603c87421d",
104
104
  "powershell/resources/assets/examples/README.md": "a0ad7c4631b6944a22edd0c2d23fe0bc66365ac7",
@@ -229,9 +229,9 @@
229
229
  "powershell/resources/psruntime/BuildTime/Models/PsHelpMarkdownOutputs.cs": "056be554968d76667c0659d169f674ef5dbb74ed",
230
230
  "powershell/resources/psruntime/BuildTime/Models/PsHelpTypes.cs": "34d832146757eab7d8e1bd3feba5d411577f388a",
231
231
  "powershell/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs": "c2c068932d2e4ab31a46d566e7b24f357f68c6f8",
232
- "powershell/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs": "5e6c8cad6843493a6822bf11bec7c58251128158",
233
- "powershell/resources/psruntime/BuildTime/Models/PsProxyTypes.cs": "02649181d9f3223a04c050c5480d07a751ba7a1e",
234
- "powershell/resources/psruntime/BuildTime/PsAttributes.cs": "06d994f77ab1052048edccf0d2b6ba7e6021ce0a",
232
+ "powershell/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs": "345f1f9808087b45984e0dabc2400b1499b68c44",
233
+ "powershell/resources/psruntime/BuildTime/Models/PsProxyTypes.cs": "965ff78cb2a5e33020bb6286330f06d191b5f459",
234
+ "powershell/resources/psruntime/BuildTime/PsAttributes.cs": "42cd061f1a91cef396cd392584e7eab268c4bc3a",
235
235
  "powershell/resources/psruntime/BuildTime/PsExtensions.cs": "52083232ddc161a0f41496cbdf979d709c490194",
236
236
  "powershell/resources/psruntime/BuildTime/PsHelpers.cs": "c9bae00316dedb24a93eeebf73b2728fe9447494",
237
237
  "powershell/resources/psruntime/BuildTime/StringExtensions.cs": "83ef554ac7f477fa9cfdece0c83a9e176e2a8e4c",
@@ -349,7 +349,7 @@
349
349
  "powershell/resources/templates/methodGroupInterfaceBody.ejs": "5871bd95f962adadda1f5187ab0b5ba731dc828e",
350
350
  "powershell/resources/templates/model.ejs": "316f808f7c5ac21824e2783ffb3028b9d2bf24fc",
351
351
  "powershell/resources/templates/page.ejs": "657e785359b8255e84e8d81d0cf33340578ff654",
352
- "powershell/resources/templates/serviceClientBody.ejs": "419df180f7d011df4de547c86008b586f9da693a",
352
+ "powershell/resources/templates/serviceClientBody.ejs": "7fe8274afe08804f019388a18eac864d8a5c1f6b",
353
353
  "powershell/resources/templates/serviceClientInterface.ejs": "b529b14d48b4adc7b0e08de4668f0faaeed6a8a5",
354
354
  "powershell/resources/utils/Get-SubscriptionIdTestSafe.ps1": "5319862d3372af080cc563328c861f4378d66f4e",
355
355
  "powershell/resources/utils/Unprotect-SecureString.ps1": "cb05b51a6220840d617a439a947a359f8685a05d",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/powershell",
3
- "version": "4.0.728",
3
+ "version": "4.0.730",
4
4
  "description": "AutoRest PowerShell Cmdlet Generator",
5
5
  "main": "dist/exports.js",
6
6
  "typings": "dist/exports.d.ts",
@@ -131,7 +131,6 @@ function CreateModelCmdlet {
131
131
  }
132
132
  $Identifier = $Member.Identifier.Value
133
133
  $Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
134
- $Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
135
134
  if ($Type.StartsWith("System.Collections.Generic.List"))
136
135
  {
137
136
  # if the type is a list, we need to convert it to array
@@ -193,6 +192,7 @@ ${ObjectTypeWithNamespace}
193
192
  ${$project.helpLinkPrefix}${ModuleName}/${cmdletNameInLowerCase}
194
193
  #>
195
194
  function ${cmdletName} {
195
+ [${$project.projectNamespace}.ModelCmdletAttribute()]
196
196
  [OutputType('${ObjectTypeWithNamespace}')]
197
197
  [CmdletBinding(PositionalBinding=`$false)]
198
198
  Param(
@@ -216,6 +216,21 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
216
216
  {Indent}{Indent}[Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)";
217
217
  }
218
218
 
219
+ private string GetLoginVerification()
220
+ {
221
+ if (!VariantGroup.IsInternal && IsAzure && !VariantGroup.IsModelCmdlet)
222
+ {
223
+ return $@"
224
+ {Indent}{Indent}$context = Get-AzContext
225
+ {Indent}{Indent}if (-not $context -and -not $testPlayback) {{
226
+ {Indent}{Indent}{Indent}Write-Error ""No Azure login detected. Please run 'Connect-AzAccount' to log in.""
227
+ {Indent}{Indent}{Indent}exit
228
+ {Indent}{Indent}}}
229
+ ";
230
+ }
231
+ return "";
232
+ }
233
+
219
234
  private string GetTelemetry()
220
235
  {
221
236
  if (!VariantGroup.IsInternal && IsAzure)
@@ -248,7 +263,10 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
248
263
  {Indent}{Indent}{Indent}$PSBoundParameters['OutBuffer'] = 1
249
264
  {Indent}{Indent}}}
250
265
  {Indent}{Indent}$parameterSet = $PSCmdlet.ParameterSetName
251
- {GetTelemetry()}
266
+ {Indent}{Indent}
267
+ {Indent}{Indent}$testPlayback = $false
268
+ {Indent}{Indent}$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object {{ if ($_) {{ $testPlayback = $testPlayback -or ('Microsoft.Message.ClientRuntime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }} }}
269
+ {GetLoginVerification()}{GetTelemetry()}
252
270
  {GetParameterSetToCmdletMapping()}{GetDefaultValuesStatements()}
253
271
  {GetProcessCustomAttributesAtRuntime()}
254
272
  {Indent}{Indent}$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet)
@@ -298,8 +316,6 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
298
316
  if ("SubscriptionId".Equals(parameterName))
299
317
  {
300
318
  sb.AppendLine($"{Indent}{Indent}if (({variantListString}) -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('{parameterName}'){setCondition}) {{");
301
- sb.AppendLine($"{Indent}{Indent}{Indent}$testPlayback = $false");
302
- sb.AppendLine($"{Indent}{Indent}{Indent}$PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object {{ if ($_) {{ $testPlayback = $testPlayback -or ('Microsoft.Message.ClientRuntime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) }} }}");
303
319
  sb.AppendLine($"{Indent}{Indent}{Indent}if ($testPlayback) {{");
304
320
  sb.AppendLine($"{Indent}{Indent}{Indent}{Indent}$PSBoundParameters['{parameterName}'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1')");
305
321
  sb.AppendLine($"{Indent}{Indent}{Indent}}} else {{");
@@ -49,6 +49,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
49
49
  public PsHelpInfo HelpInfo { get; }
50
50
  public bool IsGenerated { get; }
51
51
  public bool IsInternal { get; }
52
+ public bool IsModelCmdlet { get; }
52
53
  public string OutputFolder { get; }
53
54
  public string FileName { get; }
54
55
  public string FilePath { get; }
@@ -83,6 +84,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
83
84
  HelpInfo = Variants.Select(v => v.HelpInfo).FirstOrDefault() ?? new PsHelpInfo();
84
85
  IsGenerated = Variants.All(v => v.Attributes.OfType<GeneratedAttribute>().Any());
85
86
  IsInternal = isInternal;
87
+ IsModelCmdlet = Variants.All(v => v.IsModelCmdlet);
86
88
  OutputFolder = outputFolder;
87
89
  FileName = $"{CmdletName}{(isTest ? ".Tests" : String.Empty)}.ps1";
88
90
  FilePath = Path.Combine(OutputFolder, FileName);
@@ -143,6 +145,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
143
145
  public Parameter[] Parameters { get; }
144
146
  public Parameter[] CmdletOnlyParameters { get; }
145
147
  public bool IsInternal { get; }
148
+ public bool IsModelCmdlet { get; }
146
149
  public bool IsDoNotExport { get; }
147
150
  public bool IsNotSuggestDefaultParameterSet { get; }
148
151
  public string[] Profiles { get; }
@@ -165,6 +168,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
165
168
  Parameters = this.ToParameters().OrderBy(p => p.OrderCategory).ThenByDescending(p => p.IsMandatory).ToArray();
166
169
  IsInternal = Attributes.OfType<InternalExportAttribute>().Any();
167
170
  IsDoNotExport = Attributes.OfType<DoNotExportAttribute>().Any();
171
+ IsModelCmdlet = Attributes.OfType<ModelCmdletAttribute>().Any();
168
172
  IsNotSuggestDefaultParameterSet = Attributes.OfType<NotSuggestDefaultParameterSetAttribute>().Any();
169
173
  CmdletOnlyParameters = Parameters.Where(p => !p.Categories.Any(c => c == ParameterCategory.Azure || c == ParameterCategory.Runtime)).ToArray();
170
174
  Profiles = Attributes.OfType<ProfileAttribute>().SelectMany(pa => pa.Profiles).ToArray();
@@ -22,6 +22,11 @@ namespace Microsoft.Rest
22
22
  {
23
23
  }
24
24
 
25
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
26
+ public class ModelCmdletAttribute : Attribute
27
+ {
28
+ }
29
+
25
30
  [AttributeUsage(AttributeTargets.Class)]
26
31
  public class InternalExportAttribute : Attribute
27
32
  {
@@ -273,6 +273,9 @@ if (parameters.length > 0) {-%>
273
273
  /// <param name='rootHandler'>
274
274
  /// Optional. The http client handler used to handle http transport.
275
275
  /// </param>
276
+ /// <param name='handlers'>
277
+ /// Optional. The delegating handlers to add to the http client pipeline.
278
+ /// </param>
276
279
  /// <exception cref="System.ArgumentNullException">
277
280
  /// Thrown when a required parameter is null
278
281
  /// </exception>