Skip to content

Commit 2b550ec

Browse files
committed
updated job and joboutput to use id instead of name
1 parent 372d3dd commit 2b550ec

File tree

7 files changed

+37
-35
lines changed

7 files changed

+37
-35
lines changed

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/GetAzureAutomationJobOutput.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
2525
/// Gets azure automation variables for a given account.
2626
/// </summary>
2727
[Cmdlet(VerbsCommon.Get, "AzureAutomationJobOutput")]
28-
[OutputType(typeof(Variable))]
28+
[OutputType(typeof(JobStream))]
2929
public class GetAzureAutomationJobOutput : AzureAutomationBaseCmdlet
3030
{
3131
/// <summary>
3232
/// Gets or sets the job id
3333
/// </summary>
34-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The job id")]
34+
[Alias("JobId")]
35+
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, HelpMessage = "The job name or Id")]
3536
public Guid Id { get; set; }
3637

37-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type")]
38+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
3839
public string Stream { get; set; }
3940

40-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The start time filter for job output")]
41+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
4142
public DateTime? StartTime { get; set; }
4243

4344
/// <summary>

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/NewAzureAutomationVariable.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
1715
using System.Management.Automation;
1816
using System.Security.Permissions;
19-
using Microsoft.Azure.Commands.Automation.Common;
2017
using Microsoft.Azure.Commands.Automation.Model;
2118

2219
namespace Microsoft.Azure.Commands.Automation.Cmdlet

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public IEnumerable<JobStream> GetJobStream(string automationAccountName, Guid jo
146146

147147
if (time.HasValue)
148148
{
149-
listParams.Time = time.Value.ToUniversalTime().ToString();
149+
listParams.Time = this.FormatDateTime(time.Value);
150150
}
151151

152152
if (streamType != null)
@@ -155,8 +155,7 @@ public IEnumerable<JobStream> GetJobStream(string automationAccountName, Guid jo
155155
}
156156

157157
var jobStreams = this.automationManagementClient.JobStreams.List(automationAccountName, jobId, listParams).JobStreams;
158-
159-
return jobStreams.Select(this.CreateJobStreamFromJobStreamModel);
158+
return jobStreams.Select( stream => this.CreateJobStreamFromJobStreamModel(stream, automationAccountName, jobId)).ToList();
160159
}
161160

162161
public Variable CreateVariable(string automationAccountName, Variable variable)
@@ -314,7 +313,7 @@ public IEnumerable<Variable> ListVariables(string automationAccountName)
314313
response, response.Variables);
315314
});
316315

317-
var result = variables.Select((variable, autoamtionAccountName) => this.CreateVariableFromVariableModel(variable, automationAccountName)).ToList();
316+
var result = variables.Select(variable => this.CreateVariableFromVariableModel(variable, automationAccountName)).ToList();
318317

319318
IList<AutomationManagement.Models.EncryptedVariable> encryptedVariables = AutomationManagementClient.ContinuationTokenHandler(
320319
skipToken =>
@@ -325,7 +324,7 @@ public IEnumerable<Variable> ListVariables(string automationAccountName)
325324
response, response.EncryptedVariables);
326325
});
327326

328-
result.AddRange(encryptedVariables.Select((variable, autoamtionAccountName) => this.CreateVariableFromVariableModel(variable, automationAccountName)).ToList());
327+
result.AddRange(encryptedVariables.Select(variable => this.CreateVariableFromVariableModel(variable, automationAccountName)).ToList());
329328

330329
return result;
331330
}
@@ -344,10 +343,12 @@ public IEnumerable<Runbook> ListRunbooks(string automationAccountName)
344343
}
345344

346345
#region Private Methods
347-
private JobStream CreateJobStreamFromJobStreamModel(AutomationManagement.Models.JobStream jobStream)
346+
private JobStream CreateJobStreamFromJobStreamModel(AutomationManagement.Models.JobStream jobStream, string automationAccountName, Guid jobId)
348347
{
349348
Requires.Argument("jobStream", jobStream).NotNull();
350-
return new JobStream(jobStream);
349+
Requires.Argument("automationAccountName", automationAccountName).NotNull();
350+
Requires.Argument("jobId", jobId).NotNull();
351+
return new JobStream(jobStream, automationAccountName, jobId);
351352
}
352353

353354
private Variable CreateVariableFromVariableModel(AutomationManagement.Models.Variable variable, string automationAccountName)
@@ -607,9 +608,6 @@ public void DeleteModule(string automationAccountName, string name)
607608
}
608609
}
609610

610-
611-
612-
613611
public Job GetJob(string automationAccountName, Guid Id)
614612
{
615613
var job = this.automationManagementClient.Jobs.Get(automationAccountName, Id).Job;

src/ServiceManagement/Automation/Commands.Automation/Common/IAutomationClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface IAutomationClient
2424
{
2525
AzureSubscription Subscription { get; }
2626

27-
IEnumerable<JobStream> GetJobStream(string automationAccountname, Guid jobId, DateTime? time, string streamType);
27+
IEnumerable<JobStream> GetJobStream(string automationAccountname, Guid jonId, DateTime? time, string streamType);
2828

2929
Variable GetVariable(string automationAccountName, string variableName);
3030

src/ServiceManagement/Automation/Commands.Automation/Model/Job.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ public Job(string accountName, Azure.Management.Automation.Models.Job job)
3939
Requires.Argument("accountName", accountName).NotNull();
4040

4141
this.AutomationAccountName = accountName;
42-
this.Name = job.Name;
4342
this.Location = job.Location;
4443
this.Type = job.Type;
4544
this.Tags = job.Tags ?? new Dictionary<string, string>();
46-
this.Id = job.Id;
45+
this.Id = Guid.Parse(job.Name);
4746

4847
if (job.Properties == null) return;
4948

@@ -72,14 +71,9 @@ public Job()
7271
public string AutomationAccountName { get; set; }
7372

7473
/// <summary>
75-
/// Gets or sets the tags.
76-
/// </summary>
77-
public string Id { get; set; }
78-
79-
/// <summary>
80-
/// Gets or sets the name.
74+
/// Gets or sets the job id.
8175
/// </summary>
82-
public string Name { get; set; }
76+
public Guid Id { get; set; }
8377

8478
/// <summary>
8579
/// Gets or sets the location.

src/ServiceManagement/Automation/Commands.Automation/Model/JobStream.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ public class JobStream
3232
/// </param>
3333
/// <exception cref="System.ArgumentException">
3434
/// </exception>
35-
public JobStream(AutomationManagement.Models.JobStream jobStream)
35+
public JobStream(AutomationManagement.Models.JobStream jobStream, string automationAccountName, Guid jobId )
3636
{
3737
Requires.Argument("jobStream", jobStream).NotNull();
3838

3939
this.StreamId = jobStream.Properties.StreamId;
40-
this.StreamType = jobStream.Properties.StreamType;
41-
this.Summary = jobStream.Properties.Summary;
42-
this.Time = jobStream.Properties.Time.ToLocalTime();
40+
this.Type = jobStream.Properties.StreamType;
41+
this.Text = jobStream.Properties.Summary;
42+
this.Time = jobStream.Properties.Time;
43+
this.AutomationAccountName = automationAccountName;
44+
this.Id = jobId;
4345
}
4446

4547
/// <summary>
@@ -49,6 +51,16 @@ public JobStream()
4951
{
5052
}
5153

54+
/// <summary>
55+
/// Gets or sets the automation account name.
56+
/// </summary>
57+
public string AutomationAccountName { get; set; }
58+
59+
/// <summary>
60+
/// Gets or sets the Job Id.
61+
/// </summary>
62+
public Guid Id { get; set; }
63+
5264
/// <summary>
5365
/// Gets or sets the stream id
5466
/// </summary>
@@ -60,13 +72,13 @@ public JobStream()
6072
public DateTimeOffset Time { get; set; }
6173

6274
/// <summary>
63-
/// Gets or sets the stream summary.
75+
/// Gets or sets the stream text.
6476
/// </summary>
65-
public string Summary { get; set; }
77+
public string Text { get; set; }
6678

6779
/// <summary>
6880
/// Gets or sets the stream Type.
6981
/// </summary>
70-
public string StreamType { get; set; }
82+
public string Type { get; set; }
7183
}
7284
}

src/ServiceManagement/Automation/Commands.Automation/Model/Variable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Variable()
104104
public bool Encrypted { get; set; }
105105

106106
/// <summary>
107-
/// Gets or sets the automaiton account name.
107+
/// Gets or sets the automation account name.
108108
/// </summary>
109109
public string AutomationAccountName { get; set; }
110110
}

0 commit comments

Comments
 (0)