Skip to content

Commit fc20203

Browse files
2 parents ed63013 + 561fa8c commit fc20203

29 files changed

+2990
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 GetAzureAutomationRegistrationInfo : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Execute this cmdlet.
33+
/// </summary>
34+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
35+
public override void ExecuteCmdlet()
36+
{
37+
IEnumerable<AgentRegistration> ret = null;
38+
39+
ret = new List<AgentRegistration>
40+
{
41+
this.AutomationClient.GetAgentRegistration(
42+
this.ResourceGroupName,
43+
this.AutomationAccountName)
44+
};
45+
46+
this.GenerateCmdletOutput(ret);
47+
}
48+
49+
}
50+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 GetAzureAutomationDscConfiguration : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the configuration name.
33+
/// </summary>
34+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Position = 2, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The configuration name.")]
35+
[Alias("ConfigurationName")]
36+
[ValidateNotNullOrEmpty]
37+
public string Name { get; set; }
38+
39+
/// <summary>
40+
/// Execute this cmdlet.
41+
/// </summary>
42+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
43+
public override void ExecuteCmdlet()
44+
{
45+
IEnumerable<DscConfiguration> ret = null;
46+
if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
47+
{
48+
ret = new List<DscConfiguration>
49+
{
50+
this.AutomationClient.GetConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name)
51+
};
52+
}
53+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
54+
{
55+
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName);
56+
}
57+
58+
this.GenerateCmdletOutput(ret);
59+
}
60+
}
61+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
23+
24+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
25+
{
26+
/// <summary>
27+
/// Gets Azure automation compilation job
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJob", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
30+
[OutputType(typeof(CompilationJob))]
31+
public class GetAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// Gets or sets the job id.
35+
/// </summary>
36+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByJobId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc compilation job id.")]
37+
[Alias("JobId")]
38+
public Guid Id { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the runbook name of the job.
42+
/// </summary>
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name of the job.")]
44+
[Alias("Name")]
45+
public string ConfigurationName { get; set; }
46+
47+
/// <summary>
48+
/// Gets or sets the status of a job.
49+
/// </summary>
50+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
51+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
52+
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
53+
public string Status { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the start time filter.
57+
/// </summary>
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
59+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
60+
public DateTimeOffset? StartTime { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets the end time filter.
64+
/// </summary>
65+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
66+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
67+
public DateTimeOffset? EndTime { get; set; }
68+
69+
/// <summary>
70+
/// Execute this cmdlet.
71+
/// </summary>
72+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
73+
protected override void AutomationExecuteCmdlet()
74+
{
75+
IEnumerable<CompilationJob> jobs;
76+
77+
if (this.Id != null && !Guid.Empty.Equals(this.Id))
78+
{
79+
// ByJobId
80+
jobs = new List<CompilationJob> { this.AutomationClient.GetCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.Id) };
81+
}
82+
else if (this.ConfigurationName != null)
83+
{
84+
// ByConfiguration
85+
jobs = this.AutomationClient.ListCompilationJobsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.StartTime, this.EndTime, this.Status);
86+
}
87+
else
88+
{
89+
// ByAll
90+
jobs = this.AutomationClient.ListCompilationJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status);
91+
}
92+
93+
this.WriteObject(jobs, true);
94+
}
95+
}
96+
}
Lines changed: 57 additions & 0 deletions
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;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
23+
24+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
25+
{
26+
/// <summary>
27+
/// Gets stream for a compilation job
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJobOutput")]
30+
[OutputType(typeof(JobStream))]
31+
public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// Gets or sets the job id
35+
/// </summary>
36+
[Alias("JobId")]
37+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The job Id")]
38+
public Guid Id { get; set; }
39+
40+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
41+
public StreamType Stream { get; set; }
42+
43+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
44+
public DateTimeOffset? StartTime { get; set; }
45+
46+
/// <summary>
47+
/// Execute this cmdlet.
48+
/// </summary>
49+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
50+
protected override void AutomationExecuteCmdlet()
51+
{
52+
var ret = this.AutomationClient.GetDscCompilationJobStream(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.StartTime, this.Stream.ToString());
53+
54+
this.GenerateCmdletOutput(ret);
55+
}
56+
}
57+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Security.Permissions;
19+
using Microsoft.Azure.Commands.Automation.Common;
20+
using Microsoft.Azure.Commands.Automation.Model;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
24+
{
25+
/// <summary>
26+
/// Gets azure automation dsc node.
27+
/// </summary>
28+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscNode", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
29+
[OutputType(typeof(DscNode))]
30+
public class GetAzureAutomationDscNode : AzureAutomationBaseCmdlet
31+
{
32+
/// <summary>
33+
/// Gets or sets the job id.
34+
/// </summary>
35+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ById, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc node id.")]
36+
[Alias("NodeId")]
37+
public Guid Id { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets the status of a dsc node.
41+
/// </summary>
42+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
44+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
45+
[ValidateSet("Compliant", "Not Compliant", "Failed", "Pending", "Received", "Unresponsive")]
46+
public string Status { get; set; }
47+
48+
/// <summary>
49+
/// Gets or sets the node name.
50+
/// </summary>
51+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The node name.")]
52+
[ValidateNotNullOrEmpty]
53+
public string Name { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the nodeconfiguration name.
57+
/// </summary>
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = true, HelpMessage = "The nodeconfiguration name.")]
59+
[ValidateNotNullOrEmpty]
60+
public string NodeConfigurationName { get; set; }
61+
62+
/// <summary>
63+
/// Execute this cmdlet.
64+
/// </summary>
65+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
66+
public override void ExecuteCmdlet()
67+
{
68+
IEnumerable<DscNode> ret = null;
69+
70+
if (this.ParameterSetName == AutomationCmdletParameterSets.ById)
71+
{
72+
ret = new List<DscNode>
73+
{
74+
this.AutomationClient.GetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id)
75+
};
76+
}
77+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByName)
78+
{
79+
ret = this.AutomationClient.ListDscNodesByName(
80+
this.ResourceGroupName,
81+
this.AutomationAccountName,
82+
this.Name,
83+
this.Status);
84+
}
85+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByNodeConfiguration)
86+
{
87+
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(
88+
this.ResourceGroupName,
89+
this.AutomationAccountName,
90+
this.NodeConfigurationName,
91+
this.Status);
92+
}
93+
else
94+
{
95+
// ByAll
96+
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, this.Status);
97+
}
98+
99+
this.GenerateCmdletOutput(ret);
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)