Skip to content

Commit 7b5b447

Browse files
Saving ARM port work 1
1 parent 7ded0f7 commit 7b5b447

File tree

52 files changed

+5158
-26
lines changed

Some content is hidden

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

52 files changed

+5158
-26
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.Model;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets a certificate for automation.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationCertificate", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(CertificateInfo))]
29+
public class GetAzureAutomationCertificate : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the certificate name.
33+
/// </summary>
34+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByCertificateName, Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The certificate name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string Name { get; set; }
37+
38+
/// <summary>
39+
/// Execute this cmdlet.
40+
/// </summary>
41+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
42+
protected override void AutomationExecuteCmdlet()
43+
{
44+
IEnumerable<CertificateInfo> ret = null;
45+
if (this.ParameterSetName == AutomationCmdletParameterSets.ByCertificateName)
46+
{
47+
ret = new List<CertificateInfo>
48+
{
49+
this.AutomationClient.GetCertificate(this.ResourceGroupName, this.AutomationAccountName, this.Name)
50+
};
51+
this.GenerateCmdletOutput(ret);
52+
}
53+
else
54+
{
55+
var nextLink = string.Empty;
56+
57+
do
58+
{
59+
ret = this.AutomationClient.ListCertificates(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
60+
this.GenerateCmdletOutput(ret);
61+
62+
} while (!string.IsNullOrEmpty(nextLink));
63+
}
64+
}
65+
}
66+
}
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+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Security.Permissions;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets a connection for automation.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationConnection", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(Connection))]
29+
public class GetAzureAutomationConnection : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the connection name.
33+
/// </summary>
34+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConnectionName, Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The connection name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string Name { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the connection name.
40+
/// </summary>
41+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConnectionTypeName, Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The connection name.")]
42+
[ValidateNotNullOrEmpty]
43+
public string ConnectionTypeName { get; set; }
44+
45+
/// <summary>
46+
/// Execute this cmdlet.
47+
/// </summary>
48+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
49+
protected override void AutomationExecuteCmdlet()
50+
{
51+
IEnumerable<Connection> ret = null;
52+
if (this.ParameterSetName == AutomationCmdletParameterSets.ByConnectionName)
53+
{
54+
ret = new List<Connection>
55+
{
56+
this.AutomationClient.GetConnection(this.ResourceGroupName, this.AutomationAccountName, this.Name)
57+
};
58+
this.GenerateCmdletOutput(ret);
59+
}
60+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByConnectionTypeName)
61+
{
62+
ret = this.AutomationClient.ListConnectionsByType(this.ResourceGroupName, this.AutomationAccountName, this.ConnectionTypeName);
63+
this.GenerateCmdletOutput(ret);
64+
}
65+
else
66+
{
67+
var nextLink = string.Empty;
68+
69+
do
70+
{
71+
ret = this.AutomationClient.ListConnections(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
72+
this.GenerateCmdletOutput(ret);
73+
74+
} while (!string.IsNullOrEmpty(nextLink));
75+
}
76+
}
77+
}
78+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.Model;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets a Credential for automation.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationCredential", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(CredentialInfo))]
29+
public class GetAzureAutomationCredential : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the credential name.
33+
/// </summary>
34+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The credential name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string Name { get; set; }
37+
38+
/// <summary>
39+
/// Execute this cmdlet.
40+
/// </summary>
41+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
42+
protected override void AutomationExecuteCmdlet()
43+
{
44+
IEnumerable<CredentialInfo> ret = null;
45+
if (!string.IsNullOrEmpty(this.Name))
46+
{
47+
ret = new List<CredentialInfo>
48+
{
49+
this.AutomationClient.GetCredential(this.ResourceGroupName, this.AutomationAccountName, this.Name)
50+
};
51+
52+
this.GenerateCmdletOutput(ret);
53+
}
54+
else
55+
{
56+
var nextLink = string.Empty;
57+
58+
do
59+
{
60+
ret = this.AutomationClient.ListCredentials(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
61+
this.GenerateCmdletOutput(ret);
62+
63+
} while (!string.IsNullOrEmpty(nextLink));
64+
}
65+
}
66+
}
67+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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.Model;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets a Job object for automation.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationJob", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(Microsoft.Azure.Commands.Automation.Model.Job))]
29+
public class GetAzureAutomationJob : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the job id.
33+
/// </summary>
34+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByJobId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The job id.")]
35+
[Alias("JobId")]
36+
public Guid Id { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the runbook name of the job.
40+
/// </summary>
41+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = true, HelpMessage = "The runbook name of the job.")]
42+
[Alias("Name")]
43+
public string RunbookName { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the status of a job.
47+
/// </summary>
48+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "The runbook name of the job.")]
49+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
50+
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
51+
public string Status { get; set; }
52+
53+
/// <summary>
54+
/// Gets or sets the start time filter.
55+
/// </summary>
56+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
57+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
58+
public DateTimeOffset? StartTime { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the end time filter.
62+
/// </summary>
63+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByRunbookName, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
64+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
65+
public DateTimeOffset? EndTime { get; set; }
66+
67+
/// <summary>
68+
/// Execute this cmdlet.
69+
/// </summary>
70+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
71+
protected override void AutomationExecuteCmdlet()
72+
{
73+
IEnumerable<Microsoft.Azure.Commands.Automation.Model.Job> jobs = null;
74+
75+
if (this.Id != null && !Guid.Empty.Equals(this.Id))
76+
{
77+
// ByJobId
78+
jobs = new List<Microsoft.Azure.Commands.Automation.Model.Job> { this.AutomationClient.GetJob(this.ResourceGroupName, this.AutomationAccountName, this.Id) };
79+
this.WriteObject(jobs, true);
80+
}
81+
else if (this.RunbookName != null)
82+
{
83+
// ByRunbookName
84+
var nextLink = string.Empty;
85+
86+
do
87+
{
88+
jobs = this.AutomationClient.ListJobsByRunbookName(this.ResourceGroupName, this.AutomationAccountName, this.RunbookName, this.StartTime, this.EndTime, this.Status, ref nextLink);
89+
this.WriteObject(jobs, true);
90+
91+
} while (!string.IsNullOrEmpty(nextLink));
92+
}
93+
else
94+
{
95+
// ByAll
96+
var nextLink = string.Empty;
97+
98+
do
99+
{
100+
jobs = this.AutomationClient.ListJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status, ref nextLink);
101+
this.WriteObject(jobs, true);
102+
103+
} while (!string.IsNullOrEmpty(nextLink));
104+
}
105+
}
106+
}
107+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets azure automation variables for a given account.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationJobOutput")]
28+
[OutputType(typeof(JobStream))]
29+
public class GetAzureAutomationJobOutput : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the job id
33+
/// </summary>
34+
[Alias("JobId")]
35+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The job name or Id")]
36+
public Guid Id { get; set; }
37+
38+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
39+
public StreamType Stream { get; set; }
40+
41+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
42+
public DateTimeOffset? StartTime { get; set; }
43+
44+
/// <summary>
45+
/// Execute this cmdlet.
46+
/// </summary>
47+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
48+
protected override void AutomationExecuteCmdlet()
49+
{
50+
var nextLink = string.Empty;
51+
52+
do
53+
{
54+
var ret = this.AutomationClient.GetJobStream(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.StartTime, this.Stream.ToString(), ref nextLink);
55+
this.GenerateCmdletOutput(ret);
56+
57+
} while (!string.IsNullOrEmpty(nextLink));
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)