Skip to content

Commit 6aff57e

Browse files
committed
initial work on new stacks api
1 parent 539efb8 commit 6aff57e

File tree

47 files changed

+1950
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1950
-481
lines changed

src/Accounts/Accounts/Accounts.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<PsModuleName>Accounts</PsModuleName>
5+
<Configurations>Debug;Release;Powershell</Configurations>
56
</PropertyGroup>
67

78
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />

src/Accounts/Accounts/Properties/Resources.Designer.cs

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Authentication.ResourceManager/Authentication.ResourceManager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<PsModuleName>Accounts</PsModuleName>
5+
<Configurations>Debug;Release;Powershell</Configurations>
56
</PropertyGroup>
67

78
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />

src/Accounts/Authentication/Authentication.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<PsModuleName>Accounts</PsModuleName>
5+
<Configurations>Debug;Release;Powershell</Configurations>
56
</PropertyGroup>
67

78
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />

src/Accounts/Authentication/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Authenticators/Authenticators.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
<OutputPath>bin\$(Configuration)</OutputPath>
11+
<Configurations>Debug;Release;Powershell</Configurations>
1112
</PropertyGroup>
1213

1314
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
1415
<DelaySign>false</DelaySign>
1516
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
1617
</PropertyGroup>
1718

19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Powershell|AnyCPU'">
20+
<DelaySign>false</DelaySign>
21+
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants>
22+
</PropertyGroup>
23+
1824
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1925
<SignAssembly>true</SignAssembly>
2026
<DelaySign>true</DelaySign>

src/Monitor/Monitor/Monitor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<PsModuleName>Monitor</PsModuleName>
5+
<Configurations>Debug;Release;Powershell</Configurations>
56
</PropertyGroup>
67

78
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
16+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
17+
{
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
22+
using System.Text;
23+
24+
[Cmdlet("Export", Common.AzureRMConstants.AzureRMPrefix + "ManagementGroupDeploymentStackTemplate",
25+
DefaultParameterSetName = ExportAzResourceGroupDeploymentStackTemplate.ExportByDeploymentStackName)]
26+
internal class ExportAzManagmentGroupDeploymentStackTemplate
27+
{
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
16+
{
17+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
19+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20+
using System;
21+
using System.Management.Automation;
22+
23+
[Cmdlet("Export", Common.AzureRMConstants.AzureRMPrefix + "ResourceGroupDeploymentStackTemplate",
24+
DefaultParameterSetName = ExportAzResourceGroupDeploymentStackTemplate.ExportByDeploymentStackName)]
25+
public class ExportAzResourceGroupDeploymentStackTemplate : DeploymentStacksCmdletBase
26+
{
27+
#region Cmdlet Parameters and Parameter Set Definitions
28+
29+
internal const string ExportByResourceIdParameterSetName = "ExportDeploymentStackTemplateByResourceId";
30+
internal const string ExportByDeploymentStackName = "ExportDeploymentStackTemplateByStackName";
31+
32+
[Alias("Id")]
33+
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ExportByResourceIdParameterSetName)]
34+
[ValidateNotNullOrEmpty]
35+
public string ResourceId { get; set; }
36+
37+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ExportByDeploymentStackName)]
38+
[ValidateNotNullOrEmpty]
39+
public string ResourceGroupName { get; set; }
40+
41+
[Alias("StackName")]
42+
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ExportByDeploymentStackName)]
43+
[ValidateNotNullOrEmpty]
44+
public string Name { get; set; }
45+
46+
47+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The path to the folder where the deployment stack template will be output to.")]
48+
[ValidateNotNullOrEmpty]
49+
public string OutputFolder { get; set; }
50+
51+
#endregion
52+
53+
#region Cmdlet Overrides
54+
55+
protected override void OnProcessRecord()
56+
{
57+
try
58+
{
59+
SdkModels.PSDeploymentStack stack;
60+
switch (ParameterSetName)
61+
{
62+
case ExportByResourceIdParameterSetName:
63+
stack = DeploymentStacksSdkClient.GetResourceGroupDeploymentStack(ResourceIdUtility.GetResourceGroupName(ResourceId), ResourceIdUtility.GetDeploymentName(ResourceId));
64+
break;
65+
case ExportByDeploymentStackName:
66+
stack = DeploymentStacksSdkClient.GetResourceGroupDeploymentStack(ResourceGroupName, Name);
67+
break;
68+
default:
69+
throw new PSInvalidOperationException();
70+
}
71+
72+
73+
// Ensure our output path is resolved based on the current powershell working
74+
// directory instead of the current process directory:
75+
OutputFolder = ResolveUserPath(OutputFolder);
76+
77+
string path = FileUtility.SaveTemplateFile(
78+
templateName: this.Name,
79+
contents: stack.template.ToString(),
80+
outputPath: fullRootTemplateFilePath,
81+
overwrite: true,
82+
shouldContinue: ShouldContinue);
83+
84+
WriteObject(PowerShellUtilities.ConstructPSObject(null, "Path", fullRootTemplateFilePath));
85+
}
86+
catch (Exception ex)
87+
{
88+
WriteExceptionError(ex);
89+
}
90+
}
91+
#endregion
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
16+
{
17+
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
19+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
20+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
using System;
23+
using System.Management.Automation;
24+
25+
[Cmdlet("Export", Common.AzureRMConstants.AzureRMPrefix + "SubscriptionDeploymentStackTemplate",
26+
DefaultParameterSetName = ExportAzSubscriptionDeploymentStackTemplate.ExportByDeploymentStackName)]
27+
public class ExportAzSubscriptionDeploymentStackTemplate : DeploymentStacksCmdletBase
28+
{
29+
#region Cmdlet Parameters and Parameter Set Definitions
30+
31+
internal const string ExportByResourceIdParameterSetName = "ExportDeploymentStackTemplateByResourceId";
32+
internal const string ExportByDeploymentStackName = "ExportDeploymentStackTemplateByStackName";
33+
34+
[Alias("Id")]
35+
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ExportByResourceIdParameterSetName)]
36+
[ValidateNotNullOrEmpty]
37+
public string ResourceId { get; set; }
38+
39+
[Alias("StackName")]
40+
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ExportByDeploymentStackName)]
41+
[ValidateNotNullOrEmpty]
42+
public string Name { get; set; }
43+
44+
45+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The path to the folder where the deployment stack template will be output to.")]
46+
[ValidateNotNullOrEmpty]
47+
public string OutputFile { get; set; }
48+
49+
#endregion
50+
51+
#region Cmdlet Overrides
52+
protected override void OnProcessRecord()
53+
{
54+
try
55+
{
56+
SdkModels.PSDeploymentStack stack;
57+
switch (ParameterSetName)
58+
{
59+
case ExportByResourceIdParameterSetName:
60+
stack = DeploymentStacksSdkClient.GetSubscriptionDeploymentStack(ResourceIdUtility.GetResourceGroupName(ResourceId));
61+
break;
62+
case ExportByDeploymentStackName:
63+
stack = DeploymentStacksSdkClient.GetSubscriptionDeploymentStack(Name);
64+
break;
65+
default:
66+
throw new PSInvalidOperationException();
67+
}
68+
69+
// Ensure our output path is resolved based on the current powershell working
70+
// directory instead of the current process directory:
71+
OutputFile = ResolveUserPath(OutputFile);
72+
73+
var contents = stack.ToString();
74+
75+
string path = FileUtility.SaveTemplateFile(
76+
templateName: this.Name,
77+
contents: contents,
78+
outputPath: this.OutputFile,
79+
overwrite: true,
80+
shouldContinue: ShouldContinue);
81+
82+
WriteObject(PowerShellUtilities.ConstructPSObject(null, "Path", OutputFile));
83+
}
84+
catch (Exception ex)
85+
{
86+
WriteExceptionError(ex);
87+
}
88+
}
89+
90+
91+
#endregion
92+
}
93+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
16+
{
17+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
22+
using System.Text;
23+
24+
[Cmdlet("Get", Common.AzureRMConstants.AzureRMPrefix + "ManagementGroupDeploymentStack",
25+
DefaultParameterSetName = GetAzManagementGroupDeploymentStack.ListParameterSetname), OutputType(typeof(PSDeploymentStack))]
26+
public class GetAzManagementGroupDeploymentStack : DeploymentStacksCmdletBase
27+
{
28+
#region Cmdlet Parameters and Parameter Set Definitions
29+
30+
internal const string GetByStackNameParameterSetname = "GetIndividualDeploymentStack";
31+
internal const string GetByResourceIdParameterSetName = "GetDeploymentStackByResourceId";
32+
internal const string ListParameterSetname = "ListDeploymentStacks";
33+
34+
[Alias("StackName")]
35+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByStackNameParameterSetname,
36+
HelpMessage = "The name of the deploymentStack to get")]
37+
[ValidateNotNullOrEmpty]
38+
public string Name { get; set; }
39+
40+
[Alias("Id")]
41+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByResourceIdParameterSetName,
42+
HelpMessage = "ResourceId of the stack to get")]
43+
[ValidateNotNullOrEmpty]
44+
public string ResourceId { get; set; }
45+
46+
#endregion
47+
48+
#region Cmdlet Overrides
49+
50+
protected override void OnProcessRecord()
51+
{
52+
try
53+
{
54+
this.GetResourcesClient();
55+
switch (ParameterSetName)
56+
{
57+
case GetByStackNameParameterSetname:
58+
WriteObject(DeploymentStacksSdkClient.GetManagementGroupDeploymentStack(Name), true);
59+
break;
60+
case GetByResourceIdParameterSetName:
61+
WriteObject(DeploymentStacksSdkClient.GetManagementGroupDeploymentStack(ResourceIdUtility.GetResourceName(ResourceId)), true);
62+
break;
63+
case ListParameterSetname:
64+
WriteObject(DeploymentStacksSdkClient.ListManagementGroupDeploymentStack(), true);
65+
break;
66+
default:
67+
throw new PSInvalidOperationException();
68+
}
69+
}
70+
catch (Exception ex)
71+
{
72+
WriteExceptionError(ex);
73+
}
74+
}
75+
76+
#endregion
77+
}
78+
}

0 commit comments

Comments
 (0)