Skip to content

Commit 8644d02

Browse files
author
maddieclayton
authored
Merge pull request Azure#4749 from maddieclayton/LocationCompleterNetwork
Add LocationCompleter to Compute cmdlets
2 parents bfa9807 + bde8672 commit 8644d02

16 files changed

+30
-7
lines changed

src/ResourceManager/Common/Commands.ResourceManager.Common/Location/LocationCompleter.cs renamed to src/ResourceManager/Common/Commands.ResourceManager.Common/ArgumentCompleter/LocationCompleter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected static IDictionary<string, ICollection<string>> ResourceTypeLocationDi
9696
/// Example: [Parameter(ParameterSetName = ListByNameInTenantParameterSet, ValueFromPipelineByPropertyName = true, Mandatory = false), LocationCompleter(new string[] { "Microsoft.Batch/operationss" })]
9797
/// </summary>
9898
/// <param name="resourceTypes"></param>
99-
public LocationCompleterAttribute(string[] resourceTypes) : base(CreateScriptBlock(resourceTypes))
99+
public LocationCompleterAttribute(params string[] resourceTypes) : base(CreateScriptBlock(resourceTypes))
100100
{
101101
}
102102

src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
<Compile Include="Generated\TenantsOperations.cs" />
178178
<Compile Include="Generated\TenantsOperationsExtensions.cs" />
179179
<Compile Include="GlobalSuppressions.cs" />
180-
<Compile Include="Location\LocationCompleter.cs" />
180+
<Compile Include="ArgumentCompleter\LocationCompleter.cs" />
181181
<Compile Include="PaginatedResponseHelper.cs" />
182182
<Compile Include="Properties\AssemblyInfo.cs" />
183183
<Compile Include="Properties\Resources.Designer.cs">

src/ResourceManager/Compute/Commands.Compute/AvailabilitySets/NewAzureAvailabilitySetCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using AutoMapper;
1616
using Microsoft.Azure.Commands.Compute.Common;
1717
using Microsoft.Azure.Commands.Compute.Models;
18+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1819
using Microsoft.Azure.Management.Compute.Models;
1920
using System;
2021
using System.Management.Automation;
@@ -47,6 +48,7 @@ public class NewAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet
4748
Position = 2,
4849
ValueFromPipelineByPropertyName = true,
4950
HelpMessage = "The location.")]
51+
[LocationCompleter("Microsoft.Compute/availabilitySets")]
5052
[ValidateNotNullOrEmpty]
5153
public string Location { get; set; }
5254

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/SetAzureVMDscExtensionCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Azure.Commands.Common.Authentication.Models;
44
using Microsoft.Azure.Commands.Compute.Common;
55
using Microsoft.Azure.Commands.Compute.Models;
6+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
67
using Microsoft.Azure.Management.Compute.Models;
78
using Microsoft.WindowsAzure.Commands.Common.Extensions.DSC;
89
using Microsoft.WindowsAzure.Storage;
@@ -171,6 +172,7 @@ public class SetAzureVMDscExtensionCommand : VirtualMachineExtensionBaseCmdlet
171172
Mandatory = false,
172173
ValueFromPipelineByPropertyName = true,
173174
HelpMessage = "Location of the resource.")]
175+
[LocationCompleter("Microsoft.Storage/storageAccounts")]
174176
[ValidateNotNullOrEmpty]
175177
public string Location { get; set; }
176178

src/ResourceManager/Compute/Commands.Compute/Extension/Diagnostics/SetAzureRmVMDiagnosticsExtension.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.Azure.Commands.Common.Authentication.Models;
1919
using Microsoft.Azure.Commands.Compute.Common;
2020
using Microsoft.Azure.Commands.Compute.Models;
21+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
2122
using Microsoft.Azure.Management.Compute;
2223
using Microsoft.Azure.Management.Compute.Models;
2324
using Microsoft.Azure.Management.Storage;
@@ -105,6 +106,7 @@ public string DiagnosticsConfigurationPath
105106
Position = 7,
106107
ValueFromPipelineByPropertyName = true,
107108
HelpMessage = "The location.")]
109+
[LocationCompleter("Microsoft.Storage/storageAccounts")]
108110
public string Location
109111
{
110112
get

src/ResourceManager/Compute/Commands.Compute/Extension/SetAzureVMExtensionBaseCmdlet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1516
using System.Management.Automation;
1617

1718
namespace Microsoft.Azure.Commands.Compute
@@ -55,6 +56,7 @@ public class SetAzureVMExtensionBaseCmdlet : VirtualMachineExtensionBaseCmdlet
5556
Mandatory = false,
5657
ValueFromPipelineByPropertyName = true,
5758
HelpMessage = "The location.")]
59+
[LocationCompleter("Microsoft.Compute/virtualMachines")]
5860
[ValidateNotNullOrEmpty]
5961
public string Location { get; set; }
6062

src/ResourceManager/Compute/Commands.Compute/Extension/SqlServer/SetAzureVMSqlServerExtensionCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using AutoMapper;
1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using Microsoft.Azure.Management.Compute;
1819
using Microsoft.Azure.Management.Compute.Models;
1920
using Newtonsoft.Json;
@@ -94,6 +95,7 @@ public class SetAzureSqlServerExtensionCommand : VirtualMachineExtensionBaseCmdl
9495
Position = 8,
9596
ValueFromPipelineByPropertyName = true,
9697
HelpMessage = "Location of the resource.")]
98+
[LocationCompleter("Microsoft.Compute/virtualMachines")]
9799
[ValidateNotNullOrEmpty]
98100
public string Location { get; set; }
99101

src/ResourceManager/Compute/Commands.Compute/ExtensionImages/GetAzureVMExtensionImageCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using Microsoft.Azure.Management.Compute.Models;
1819
using Microsoft.Rest.Azure.OData;
1920
using System.Linq;
@@ -26,7 +27,7 @@ namespace Microsoft.Azure.Commands.Compute
2627
[OutputType(typeof(PSVirtualMachineExtensionImageDetails))]
2728
public class GetAzureVMExtensionImageCommand : VirtualMachineExtensionImageBaseCmdlet
2829
{
29-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
30+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
3031
public string Location { get; set; }
3132

3233
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]

src/ResourceManager/Compute/Commands.Compute/ExtensionImages/GetAzureVMExtensionImageTypeCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using System.Linq;
1819
using System.Management.Automation;
1920

@@ -23,7 +24,7 @@ namespace Microsoft.Azure.Commands.Compute
2324
[OutputType(typeof(PSVirtualMachineExtensionImageType))]
2425
public class GetAzureVMExtensionImageTypeCommand : VirtualMachineExtensionImageBaseCmdlet
2526
{
26-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
27+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
2728
public string Location { get; set; }
2829

2930
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]

src/ResourceManager/Compute/Commands.Compute/Images/GetAzureVMImageCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using Microsoft.Azure.Management.Compute.Models;
1819
using Microsoft.Rest.Azure.OData;
1920
using System.Linq;
@@ -38,6 +39,7 @@ public class GetAzureVMImageCommand : VirtualMachineImageBaseCmdlet
3839
[Parameter(ParameterSetName = GetVMImageDetailParamSetName,
3940
Mandatory = true,
4041
ValueFromPipelineByPropertyName = true)]
42+
[LocationCompleter("Microsoft.Compute/locations/publishers")]
4143
[ValidateNotNullOrEmpty]
4244
public string Location { get; set; }
4345

src/ResourceManager/Compute/Commands.Compute/Images/GetAzureVMImageOfferCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using System.Linq;
1819
using System.Management.Automation;
1920

@@ -23,7 +24,7 @@ namespace Microsoft.Azure.Commands.Compute
2324
[OutputType(typeof(PSVirtualMachineImageOffer))]
2425
public class GetAzureVMImageOfferCommand : VirtualMachineImageBaseCmdlet
2526
{
26-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
27+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
2728
public string Location { get; set; }
2829

2930
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]

src/ResourceManager/Compute/Commands.Compute/Images/GetAzureVMImagePublisherCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using System.Linq;
1819
using System.Management.Automation;
1920

@@ -23,7 +24,7 @@ namespace Microsoft.Azure.Commands.Compute
2324
[OutputType(typeof(PSVirtualMachineImagePublisher))]
2425
public class GetAzureVMImagePublisherCommand : VirtualMachineImageBaseCmdlet
2526
{
26-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
27+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
2728
public string Location { get; set; }
2829

2930
public override void ExecuteCmdlet()

src/ResourceManager/Compute/Commands.Compute/Images/GetAzureVMImageSkuCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using Microsoft.Azure.Commands.Compute.Common;
1616
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1718
using System.Linq;
1819
using System.Management.Automation;
1920

@@ -23,7 +24,7 @@ namespace Microsoft.Azure.Commands.Compute
2324
[OutputType(typeof(PSVirtualMachineImageSku))]
2425
public class GetAzureVMImageSkuCommand : VirtualMachineImageBaseCmdlet
2526
{
26-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
27+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
2728
public string Location { get; set; }
2829

2930
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]

src/ResourceManager/Compute/Commands.Compute/Usage/GetAzureVMUsageCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using AutoMapper;
1616
using Microsoft.Azure.Commands.Compute.Common;
1717
using Microsoft.Azure.Commands.Compute.Models;
18+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1819
using Microsoft.Azure.Management.Compute.Models;
1920
using Microsoft.Rest.Azure;
2021
using System.Collections.Generic;
@@ -31,6 +32,7 @@ public class GetAzureVMUsageCommand : VirtualMachineUsageBaseCmdlet
3132
Position = 0,
3233
ValueFromPipelineByPropertyName = true,
3334
HelpMessage = "The location name.")]
35+
[LocationCompleter("Microsoft.Compute/locations/usages")]
3436
[ValidateNotNullOrEmpty]
3537
public string Location { get; set; }
3638

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.Azure.Commands.Common.Authentication.Models;
1919
using Microsoft.Azure.Commands.Compute.Common;
2020
using Microsoft.Azure.Commands.Compute.Models;
21+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
2122
using Microsoft.Azure.Management.Compute;
2223
using Microsoft.Azure.Management.Compute.Models;
2324
using Microsoft.Azure.Management.Storage;
@@ -46,6 +47,7 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
4647
Mandatory = true,
4748
Position = 1,
4849
ValueFromPipelineByPropertyName = true)]
50+
[LocationCompleter("Microsoft.Compute/virtualMachines")]
4951
[ValidateNotNullOrEmpty]
5052
public string Location { get; set; }
5153

src/ResourceManager/Compute/Commands.Compute/VirtualMachineSizes/GetAzureVMSizeCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using AutoMapper;
1616
using Microsoft.Azure.Commands.Compute.Common;
1717
using Microsoft.Azure.Commands.Compute.Models;
18+
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
1819
using Microsoft.Azure.Management.Compute.Models;
1920
using Microsoft.Rest.Azure;
2021
using System.Collections.Generic;
@@ -36,6 +37,7 @@ public class GetAzureVMSizeCommand : VirtualMachineSizeBaseCmdlet
3637
ParameterSetName = ListVirtualMachineSizeParamSet,
3738
ValueFromPipelineByPropertyName = true,
3839
HelpMessage = "The location name.")]
40+
[LocationCompleter("Microsoft.Compute/locations/vmSizes")]
3941
[ValidateNotNullOrEmpty]
4042
public string Location { get; set; }
4143

0 commit comments

Comments
 (0)