You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some generated cmdlets include PowerShell `SupportsShouldProcess` semantics, exposing `-WhatIf` and `-Confirm`. This is appropriate for operations that can change state. However, certain service operations use non-GET HTTP methods (e.g., `POST /.../listKeys`) while remaining logically read-only. For these, displaying `-WhatIf` and `-Confirm` is misleading.
215
+
216
+
Use `suppress-should-process` to explicitly disable `SupportsShouldProcess` for selected cmdlets so that `-WhatIf` and `-Confirm` are not generated.
217
+
218
+
This directive was introduced to address scenarios like issue #704, where `listKeys` style operations were generated with unnecessary confirmation switches.
219
+
220
+
Usage:
221
+
- Target the cmdlet with the usual command filters (`verb`, `subject`, `subject-prefix`, and/or `variant`).
222
+
- Set `suppress-should-process: true` under `set`.
223
+
224
+
```yaml $false
225
+
# Disable -WhatIf / -Confirm for a logically read-only list keys operation
226
+
directive:
227
+
- where:
228
+
verb: Get
229
+
subject: RedisEnterpriseDatabaseKey
230
+
set:
231
+
suppress-should-process: true
232
+
```
233
+
234
+
Regex example:
235
+
```yaml $false
236
+
# Disable ShouldProcess for all Get-*Keys cmdlets whose subject ends with Keys
237
+
directive:
238
+
- where:
239
+
verb: Get
240
+
subject: (.*)Keys$
241
+
set:
242
+
suppress-should-process: true
243
+
```
244
+
245
+
Notes:
246
+
- Only applies to `command` targets.
247
+
- Has no effect if the cmdlet does not already support ShouldProcess.
248
+
- Use sparingly; only when you are certain the underlying operation is non-mutating.
249
+
212
250
### Parameter Rename
213
-
To select a parameter you need to provide the `parameter-name`. Furthermore, if you want to target specific cmdlets you can provide the `subject-prefix`, `subject`, `verb`, and/or `variant` (i.e. parameter-set). For example:
251
+
To select a parameter you need to provide the `parameter-name`. Furthermore, if you want to target specific cmdlets you can provide the `subject-prefix`, `subject`, `verb`, and/or `variant` (i.e. parameter-set name). For example:
214
252
```yaml false
215
253
# This will rename the parameter 'XYZName' from the cmdlet 'Get-Operation' to 'Name'.
216
254
directive:
@@ -311,7 +349,7 @@ directive:
311
349
```
312
350
313
351
### Model Cmdlet
314
-
To generate a cmdlet for a model facilitating users in constructing complex objects, you can choose the model using `model-name`. The default cmdlet name generated will be New-Az[subject-prefix][model-name]Object, and you can customize it using `cmdlet-name`. For example:
352
+
To generate a cmdlet for a model facilitating users in constructing complex objects, you can choose the model using `model-name`. The default cmdlet name generated will be New-Az[subject-prefix][model-name]Object (or equivalent based on module naming). For example:
315
353
```yaml $false
316
354
- model-cmdlet:
317
355
- model-name: Workspace
@@ -345,7 +383,7 @@ directive:
345
383
```
346
384
347
385
### Alias Removal
348
-
If the option `--sanitize-names` or `--azure` is provided, AutoRest will make renames to cmdlets and parameters to remove redundancies. For example in the command `Get-VirtualMachine`, the parameter `VirtualMachineName` will be renamed to `Name`, and aliased to VirtualMachineName. It is possible to eliminate that alias by providing the action `clear-alias: true`:
386
+
If the option `--sanitize-names` or `--azure` is provided, AutoRest will make renames to cmdlets and parameters to remove redundancies. For example in the command `Get-VirtualMachine`, the parameter `VirtualMachineName` may become just `Name`. To remove an automatically generated alias:
349
387
```yaml $false
350
388
directive:
351
389
- where:
@@ -355,7 +393,7 @@ directive:
355
393
The same can be done with cmdlets.
356
394
357
395
### Table Formatting
358
-
This allows you to set the *table format* for a model. This updates the `.format.ps1xml` to have the format described below as opposed to the automatic table format that is created at build-time. For example, we are updating the format for a VirtualMachine model to only show the Name and ResourceGroup properties. It updates the column label for ResourceGroup to Resource Group and sets the columns widths for Name and ResourceGroup:
396
+
This allows you to set the *table format* for a model. This updates the `.format.ps1xml` to have the format described below as opposed to the automatic table format that is created at build-time. For example:
359
397
```yaml $false
360
398
directive:
361
399
- where:
@@ -394,7 +432,7 @@ directive:
394
432
```
395
433
396
434
### Argument Completers
397
-
For parameters, you can declare argument completers that will allow you to tab through the values when entering that parameter interactively. This allows you to declare a PowerShell script that will run to get the values for the completer. For example:
435
+
For parameters, you can declare argument completers that will allow you to tab through the values when entering that parameter interactively. This allows you to declare a PowerShell script that will run to produce the possible values for that parameter.
398
436
```yaml $false
399
437
# The script should return a list of values.
400
438
directive:
@@ -409,7 +447,7 @@ directive:
409
447
The name and description are optional. They are currently unused properties that may be used in documentation generation in the future.
410
448
411
449
### Default Values
412
-
For parameters, you can declare a default value script that will run to set the value for the parameter if it is not provided. Once this is declared for a parameter, that parameter will be made optional at build-time. For example:
450
+
For parameters, you can declare a default value script that will run to set the value for the parameter if it is not provided. Once this is declared for a parameter, that parameter will be made optional (unless there are other constraints).
413
451
```yaml $false
414
452
# The script should return a value for the parameter.
415
453
directive:
@@ -425,7 +463,7 @@ The name and description are optional. They are currently unused properties that
425
463
426
464
### Polymorphism
427
465
428
-
In swagger, polymorphism is recognized as the `discriminator` keyword. The model with this keyword will be the **base class**, and the models that use `allOf` to referece the base class are the **child class**.
466
+
In swagger, polymorphism is recognized as the `discriminator` keyword. The model with this keyword will be the **base class**, and the models that use `allOf` to referece the base class are the **child classes**.
429
467
430
468
We will use two directives to support polymorphism:
0 commit comments