Skip to content

Commit ea2b86f

Browse files
authored
Merge pull request #7737 from Azure/maddieclayton-patch-2
Update dev guide with ResourceNameCompleter
2 parents 3478e8b + 437557d commit ea2b86f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

documentation/development-docs/azure-powershell-design-guidelines.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- [ResourceId](#resourceid)
4141
- [InputObject](#inputobject)
4242
- [AsJob Parameter](#asjob-parameter)
43+
- [Argument Completers](#argument-completers)
4344

4445
## Expected Patterns for Standard Cmdlets
4546

@@ -291,6 +292,22 @@ using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
291292
public string ResourceGroupName { get; set; }
292293
```
293294

295+
### Resource Name Completer
296+
297+
For any parameter that takes a resource name, the `ResourceNameCompleter` should be applied as an attribute. This will allow the user to tab through all resource names for the ResourceType in the current subscription. This completer will filter based upon the current parent resources provided (for instance, if ResourceGroupName is provided, only the resources in that particular resource group will be returned). For this completer, please provide the ResourceType as the first argument, followed by the parameter name for all parent resources starting at the top level.
298+
299+
```cs
300+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
301+
...
302+
[Parameter(Mandatory = false, HelpMessage = "The parent server name")]
303+
[ResourceNameCompleter("Microsoft.Sql/servers", nameof(ResourceGroupName))]
304+
public string ServerName { get; set; }
305+
306+
[Parameter(Mandatory = false, HelpMessage = "The database name")]
307+
[ResourceNameCompleter("Microsoft.Sql/servers/databases", nameof(ResourceGroupName), nameof(ServerName))]
308+
public string Name { get; set; }
309+
```
310+
294311
### Location Completer
295312

296313
For any parameter that takes a location, the `LocationCompleter` should be applied as an attribute. In order to use the `LocationCompleter`, you must input as an argument all of the Providers/ResourceTypes used by the cmdlet. The user will then be able to tab through locations that are valid for all of the Providers/ResourceTypes specified.

documentation/development-docs/azure-powershell-developer-guide.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,22 @@ using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
415415
public string ResourceGroupName { get; set; }
416416
```
417417

418+
### Resource Name Completer
419+
420+
For any parameter that takes a resource name, the `ResourceNameCompleter` should be applied as an attribute. This will allow the user to tab through all resource names for the ResourceType in the current subscription. This completer will filter based upon the current parent resources provided (for instance, if ResourceGroupName is provided, only the resources in that particular resource group will be returned). For this completer, please provide the ResourceType as the first argument, followed by the parameter name for all parent resources starting at the top level.
421+
422+
```cs
423+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
424+
...
425+
[Parameter(Mandatory = false, HelpMessage = "The parent server name")]
426+
[ResourceNameCompleter("Microsoft.Sql/servers", nameof(ResourceGroupName))]
427+
public string ServerName { get; set; }
428+
429+
[Parameter(Mandatory = false, HelpMessage = "The database name")]
430+
[ResourceNameCompleter("Microsoft.Sql/servers/databases", nameof(ResourceGroupName), nameof(ServerName))]
431+
public string Name { get; set; }
432+
```
433+
418434
### Location Completer
419435

420436
For any parameter that takes a location, the `LocationCompleter` should be applied as an attribute. In order to use the `LocationCompleter`, you must input as an argument all of the Providers/ResourceTypes used by the cmdlet. The user will then be able to tab through locations that are valid for all of the Providers/ResourceTypes specified.

0 commit comments

Comments
 (0)