Skip to content

Commit faa47c8

Browse files
committed
merged with prasad's branch
2 parents 593260e + e18cf79 commit faa47c8

11 files changed

+783
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets azure automation agent registration information for a given account.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationRegistrationInfo")]
28+
[OutputType(typeof(AgentRegistration))]
29+
public class GetAzureAutomationAgentRegistrationInformation : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Execute this cmdlet.
40+
/// </summary>
41+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
42+
public override void ExecuteCmdlet()
43+
{
44+
IEnumerable<AgentRegistration> ret = null;
45+
46+
ret = new List<AgentRegistration>
47+
{
48+
this.AutomationClient.GetAgentRegistration(
49+
this.ResourceGroupName,
50+
this.AutomationAccountName)
51+
};
52+
53+
this.GenerateCmdletOutput(ret);
54+
}
55+
56+
}
57+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets azure automation configurations for a given account.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(DscConfiguration))]
29+
public class GetAzureAutomationConfiguration : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the configuration name.
40+
/// </summary>
41+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Position = 2, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The configuration name.")]
42+
[Alias("ConfigurationName")]
43+
[ValidateNotNullOrEmpty]
44+
public string Name { get; set; }
45+
46+
/// <summary>
47+
/// Execute this cmdlet.
48+
/// </summary>
49+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
50+
public override void ExecuteCmdlet()
51+
{
52+
IEnumerable<DscConfiguration> ret = null;
53+
if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
54+
{
55+
ret = new List<DscConfiguration>
56+
{
57+
this.AutomationClient.GetConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name)
58+
};
59+
}
60+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
61+
{
62+
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
63+
}
64+
65+
this.GenerateCmdletOutput(ret);
66+
}
67+
}
68+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Imports dsc configuration script
26+
/// </summary>
27+
[Cmdlet(VerbsData.Import, "AzureAutomationDscConfiguration")]
28+
[OutputType(typeof(DscConfiguration))]
29+
public class ImportAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the configuration name.
40+
/// </summary>
41+
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration name.")]
42+
public string ConfigurationName { get; set; }
43+
44+
/// <summary>
45+
/// Gets or sets the source path.
46+
/// </summary>
47+
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
48+
public string SourcePath { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the description.
52+
/// </summary>
53+
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the configuration being imported.")]
54+
public string Description { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets the switch parameter to
58+
/// </summary>
59+
[Parameter(Position = 5, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Import the configuration in published state.")]
60+
public SwitchParameter Published { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
64+
/// </summary>
65+
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Overwrites an existing configuration with same name.")]
66+
public SwitchParameter Overwrite { get; set; }
67+
68+
/// <summary>
69+
/// Gets or sets a value indicating whether verbose logging should be turned on or off.
70+
/// </summary>
71+
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
72+
public bool? LogVerbose { get; set; }
73+
74+
/// <summary>
75+
/// Execute this cmdlet.
76+
/// </summary>
77+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
78+
public override void ExecuteCmdlet()
79+
{
80+
var configuration = this.AutomationClient.CreateConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.SourcePath, this.Description, this.LogVerbose);
81+
this.WriteObject(configuration);
82+
}
83+
}
84+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Regenerates the agent registration key based on the key name.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.New, "AzureAutomationKey")]
28+
[OutputType(typeof(AgentRegistration))]
29+
public class NewAzureAutomationKey : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the KeyType.
40+
/// </summary>
41+
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The key type of the agent registration key - primary or secondary")]
42+
[ValidateSet("Primary", "Secondary", IgnoreCase = true)]
43+
public string KeyType { get; set; }
44+
45+
/// <summary>
46+
/// Execute this cmdlet.
47+
/// </summary>
48+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
49+
public override void ExecuteCmdlet()
50+
{
51+
var agentRegistration = this.AutomationClient.NewAgentRegistrationKey(this.ResourceGroupName, this.AutomationAccountName, this.KeyType);
52+
this.WriteObject(agentRegistration);
53+
}
54+
}
55+
}

src/ResourceManager/Automation/Commands.Automation/Commands.ResourceManagement.Automation.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,16 @@
116116
</ItemGroup>
117117
<ItemGroup>
118118
<Compile Include="Cmdlet\AzureAutomationBaseCmdlet.cs" />
119+
<Compile Include="Cmdlet\GetAzureAutomationAgentRegistrationInformation.cs" />
120+
<Compile Include="Cmdlet\GetAzureAutomationConfiguration.cs" />
121+
<Compile Include="Cmdlet\ImportAzureAutomationDscConfiguration.cs" />
122+
<Compile Include="Cmdlet\NewAzureAutomationKey.cs" />
119123
<Compile Include="Cmdlet\SetAzureAutomationAccount.cs" />
120124
<Compile Include="Cmdlet\RemoveAzureAutomationAccount.cs" />
121125
<Compile Include="Cmdlet\NewAzureAutomationAccount.cs" />
122126
<Compile Include="Cmdlet\GetAzureAutomationAccount.cs" />
123127
<Compile Include="Common\AutomationClient.cs" />
128+
<Compile Include="Common\AutomationClientDSC.cs" />
124129
<Compile Include="Common\AutomationCmdletParameterSet.cs" />
125130
<Compile Include="Common\AzureAutomationOperationException.cs" />
126131
<Compile Include="Common\Constants.cs" />
@@ -134,8 +139,10 @@
134139
<Compile Include="DataContract\ErrorResponse.cs" />
135140
<Compile Include="DataContract\OdataError.cs" />
136141
<Compile Include="DataContract\OdataErrorMessage.cs" />
142+
<Compile Include="Model\AgentRegistration.cs" />
137143
<Compile Include="Model\AutomationAccount.cs" />
138144
<Compile Include="Model\DscCompilationJob.cs" />
145+
<Compile Include="Model\Configuration.cs" />
139146
<Compile Include="Properties\AssemblyInfo.cs" />
140147
<Compile Include="Properties\Resources.Designer.cs">
141148
<AutoGen>True</AutoGen>

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Microsoft.Azure.Commands.Automation.Common
3939
using Hyak.Common;
4040

4141

42-
public class AutomationClient : IAutomationClient
42+
public partial class AutomationClient : IAutomationClient
4343
{
4444
private readonly AutomationManagement.IAutomationManagementClient automationManagementClient;
4545

@@ -114,10 +114,10 @@ public AutomationAccount CreateAutomationAccount(string resourceGroupName, strin
114114
Name = automationAccountName,
115115
Properties = new AutomationAccountCreateOrUpdateProperties()
116116
{
117-
Sku = new Sku()
118-
{
119-
Name = String.IsNullOrWhiteSpace(plan) ? Constants.DefaultPlan : plan,
120-
}
117+
Sku = new Sku()
118+
{
119+
Name = String.IsNullOrWhiteSpace(plan) ? Constants.DefaultPlan : plan,
120+
}
121121
},
122122
Tags = accountTags
123123
};
@@ -158,7 +158,7 @@ public AutomationAccount UpdateAutomationAccount(string resourceGroupName, strin
158158
Name = String.IsNullOrWhiteSpace(plan) ? automationAccount.Plan : plan,
159159
}
160160
},
161-
Tags = accountTags,
161+
Tags = accountTags,
162162
};
163163

164164
var account =

0 commit comments

Comments
 (0)