|
14 | 14 |
|
15 | 15 | namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
|
16 | 16 | {
|
| 17 | + using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; |
17 | 18 | using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
|
18 | 19 | using System;
|
19 | 20 | using System.Collections.Generic;
|
20 | 21 | using System.Management.Automation;
|
21 | 22 | using System.Text;
|
22 | 23 |
|
23 |
| - [Cmdlet("Get", Common.AzureRMConstants.AzureRMPrefix + "ResourceGroupDeploymentStack", |
24 |
| - DefaultParameterSetName = GetAzResourceGroupDeploymentStack.ListDeploymentStack), OutputType(typeof(PSDeploymentStack))] |
| 24 | + [Cmdlet("Get", Common.AzureRMConstants.AzureRMPrefix + "DeploymentStack", |
| 25 | + DefaultParameterSetName = GetAzResourceGroupDeploymentStack.ListParameterSetName), OutputType(typeof(PSDeploymentStack))] |
25 | 26 | public class GetAzResourceGroupDeploymentStack : DeploymentStacksCmdletBase
|
26 | 27 | {
|
27 |
| - #region Cmdlet Parameters and Parameter Set Definitions |
| 28 | + internal const string ListParameterSetName = "ListDeploymentStacks"; |
| 29 | + |
| 30 | + internal const string GetByResourceIdParameterSetName = "GetDeploymentStackByResourceId"; |
| 31 | + internal const string GetByResourceGroupNameParameterSetName = "GetDeploymentStacksByResourceGroupName"; |
| 32 | + internal const string GetByDeploymentStackName = "GetDeploymentStackByStackName"; |
| 33 | + |
| 34 | + [Alias("Id")] |
| 35 | + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByResourceIdParameterSetName)] |
| 36 | + [ValidateNotNullOrEmpty] |
| 37 | + public string ResourceId { get; set; } |
| 38 | + |
| 39 | + [Alias("ResourceGroupName")] |
| 40 | + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByResourceGroupNameParameterSetName)] |
| 41 | + [Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByDeploymentStackName)] |
| 42 | + [ValidateNotNullOrEmpty] |
| 43 | + public string ResourceGroupName { get; set; } |
| 44 | + |
| 45 | + [Alias("StackName")] |
| 46 | + [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByDeploymentStackName)] |
| 47 | + [ValidateNotNullOrEmpty] |
| 48 | + public string StackName { get; set; } |
| 49 | + |
| 50 | + public override void ExecuteCmdlet() |
| 51 | + { |
| 52 | + try |
| 53 | + { |
| 54 | + switch (ParameterSetName) |
| 55 | + { |
| 56 | + case GetByResourceIdParameterSetName: |
| 57 | + WriteObject(DeploymentStacksSdkClient.GetResourceGroupDeploymentStack(ResourceIdUtility.GetResourceGroupName(ResourceId), ResourceIdUtility.GetDeploymentName(ResourceId))); |
| 58 | + break; |
| 59 | + case GetByResourceGroupNameParameterSetName: |
| 60 | + WriteObject(DeploymentStacksSdkClient.ListResourceGroupDeploymentStack(ResourceGroupName)); |
| 61 | + break; |
| 62 | + case GetByDeploymentStackName: |
| 63 | + WriteObject(DeploymentStacksSdkClient.GetResourceGroupDeploymentStack(ResourceGroupName, StackName)); |
| 64 | + break; |
| 65 | + default: |
| 66 | + throw new PSInvalidOperationException(); |
| 67 | + } |
| 68 | + } |
| 69 | + catch (Exception ex) |
| 70 | + { |
| 71 | + WriteExceptionError(ex); |
| 72 | + } |
| 73 | + |
| 74 | + } |
28 | 75 |
|
29 |
| - internal const string ListDeploymentStack = "ListDeploymentStack"; |
30 | 76 |
|
31 | 77 |
|
32 |
| - #endregion |
33 | 78 |
|
34 | 79 | }
|
35 | 80 | }
|
0 commit comments