Skip to content

Add LocationCompleter to Compute cmdlets #4749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected static IDictionary<string, ICollection<string>> ResourceTypeLocationDi
/// Example: [Parameter(ParameterSetName = ListByNameInTenantParameterSet, ValueFromPipelineByPropertyName = true, Mandatory = false), LocationCompleter(new string[] { "Microsoft.Batch/operationss" })]
/// </summary>
/// <param name="resourceTypes"></param>
public LocationCompleterAttribute(string[] resourceTypes) : base(CreateScriptBlock(resourceTypes))
public LocationCompleterAttribute(params string[] resourceTypes) : base(CreateScriptBlock(resourceTypes))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
<Compile Include="Generated\TenantsOperations.cs" />
<Compile Include="Generated\TenantsOperationsExtensions.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Location\LocationCompleter.cs" />
<Compile Include="ArgumentCompleter\LocationCompleter.cs" />
<Compile Include="PaginatedResponseHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using AutoMapper;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using System;
using System.Management.Automation;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class NewAzureAvailabilitySetCommand : AvailabilitySetBaseCmdlet
Position = 2,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The location.")]
[LocationCompleter("Microsoft.Compute/availabilitySets")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.WindowsAzure.Commands.Common.Extensions.DSC;
using Microsoft.WindowsAzure.Storage;
Expand Down Expand Up @@ -171,6 +172,7 @@ public class SetAzureVMDscExtensionCommand : VirtualMachineExtensionBaseCmdlet
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Location of the resource.")]
[LocationCompleter("Microsoft.Storage/storageAccounts")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Storage;
Expand Down Expand Up @@ -105,6 +106,7 @@ public string DiagnosticsConfigurationPath
Position = 7,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The location.")]
[LocationCompleter("Microsoft.Storage/storageAccounts")]
public string Location
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Compute
Expand Down Expand Up @@ -55,6 +56,7 @@ public class SetAzureVMExtensionBaseCmdlet : VirtualMachineExtensionBaseCmdlet
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The location.")]
[LocationCompleter("Microsoft.Compute/virtualMachines")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using AutoMapper;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Newtonsoft.Json;
Expand Down Expand Up @@ -94,6 +95,7 @@ public class SetAzureSqlServerExtensionCommand : VirtualMachineExtensionBaseCmdl
Position = 8,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Location of the resource.")]
[LocationCompleter("Microsoft.Compute/virtualMachines")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Rest.Azure.OData;
using System.Linq;
Expand All @@ -26,7 +27,7 @@ namespace Microsoft.Azure.Commands.Compute
[OutputType(typeof(PSVirtualMachineExtensionImageDetails))]
public class GetAzureVMExtensionImageCommand : VirtualMachineExtensionImageBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty, LocationCompleter("Microsoft.Compute/locations/publishers")]
public string Location { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using System.Linq;
using System.Management.Automation;

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

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Rest.Azure.OData;
using System.Linq;
Expand All @@ -38,6 +39,7 @@ public class GetAzureVMImageCommand : VirtualMachineImageBaseCmdlet
[Parameter(ParameterSetName = GetVMImageDetailParamSetName,
Mandatory = true,
ValueFromPipelineByPropertyName = true)]
[LocationCompleter("Microsoft.Compute/locations/publishers")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using System.Linq;
using System.Management.Automation;

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

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using System.Linq;
using System.Management.Automation;

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

public override void ExecuteCmdlet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using System.Linq;
using System.Management.Automation;

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

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using AutoMapper;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Rest.Azure;
using System.Collections.Generic;
Expand All @@ -31,6 +32,7 @@ public class GetAzureVMUsageCommand : VirtualMachineUsageBaseCmdlet
Position = 0,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The location name.")]
[LocationCompleter("Microsoft.Compute/locations/usages")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Storage;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
Mandatory = true,
Position = 1,
ValueFromPipelineByPropertyName = true)]
[LocationCompleter("Microsoft.Compute/virtualMachines")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using AutoMapper;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Location;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Rest.Azure;
using System.Collections.Generic;
Expand All @@ -36,6 +37,7 @@ public class GetAzureVMSizeCommand : VirtualMachineSizeBaseCmdlet
ParameterSetName = ListVirtualMachineSizeParamSet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The location name.")]
[LocationCompleter("Microsoft.Compute/locations/vmSizes")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down