Skip to content

Commit 1015341

Browse files
JobStreamRecord
1 parent e7c2cc2 commit 1015341

File tree

5 files changed

+103
-28
lines changed

5 files changed

+103
-28
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationJobOutputRecord.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class GetAzureAutomationJobOutputRecord : AzureAutomationBaseCmdlet
3636
/// <summary>
3737
/// Gets or sets the job stream id
3838
/// </summary>
39+
[Alias("OutputRecordId")]
3940
[Parameter(Mandatory = true, Position = 3, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream id")]
4041
[ValidateNotNullOrEmpty]
4142
public string JobStreamId { get; set; }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,11 @@ public IEnumerable<JobStream> GetJobStream(string resourceGroupName, string auto
989989
stream => this.CreateJobStreamFromJobStreamModel(stream, resourceGroupName, automationAccountName, jobId));
990990
}
991991

992-
public JobStream GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId)
992+
public JobStreamRecord GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId)
993993
{
994994
var response = this.automationManagementClient.JobStreams.Get(resourceGroupName, automationAccountName, jobId, jobStreamId);
995995

996-
return this.CreateJobStreamFromJobStreamModel(response.JobStream, resourceGroupName, automationAccountName, jobId);
996+
return new JobStreamRecord(response.JobStream, resourceGroupName, automationAccountName, jobId);
997997
}
998998

999999
public Job GetJob(string resourceGroupName, string automationAccountName, Guid Id)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Model.Webhook CreateWebhook(
235235
IEnumerable<JobStream> GetJobStream(string resourceGroupName, string automationAccountName, Guid jobId,
236236
DateTimeOffset? time, string streamType, ref string nextLink);
237237

238-
JobStream GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId);
238+
JobStreamRecord GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId);
239239

240240
#endregion
241241

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

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,12 @@ public JobStream(AutomationManagement.Models.JobStream jobStream, string resourc
5353
this.AutomationAccountName = automationAccountName;
5454
this.ResourceGroupName = resourceGroupName;
5555
this.Id = jobId;
56-
this.Text = jobStream.Properties.StreamText;
5756

5857
if (!String.IsNullOrWhiteSpace(jobStream.Properties.Summary))
5958
{
60-
if (jobStream.Properties.Summary.Length > Constants.JobSummaryLength)
61-
{
62-
this.Summary = jobStream.Properties.Summary.Substring(0, Constants.JobSummaryLength) + "...";
63-
}
64-
else
65-
{
66-
this.Summary = jobStream.Properties.Summary;
67-
}
68-
}
69-
70-
this.Value = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
71-
foreach (var kvp in jobStream.Properties.Value)
72-
{
73-
this.Value.Add(kvp.Key, kvp.Value);
59+
this.Summary = jobStream.Properties.Summary.Length > Constants.JobSummaryLength ?
60+
jobStream.Properties.Summary.Substring(0, Constants.JobSummaryLength) + "..." :
61+
jobStream.Properties.Summary;
7462
}
7563
}
7664

@@ -106,11 +94,6 @@ public JobStream()
10694
/// </summary>
10795
public DateTimeOffset Time { get; set; }
10896

109-
/// <summary>
110-
/// Gets or sets the stream text.
111-
/// </summary>
112-
public string Text { get; set; }
113-
11497
/// <summary>
11598
/// Gets or sets the summary.
11699
/// </summary>
@@ -120,10 +103,5 @@ public JobStream()
120103
/// Gets or sets the stream Type.
121104
/// </summary>
122105
public string Type { get; set; }
123-
124-
/// <summary>
125-
/// Gets or sets the stream values.
126-
/// </summary>
127-
public Hashtable Value { get; set; }
128106
}
129107
}
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.Management.Automation;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
20+
using AutomationManagement = Microsoft.Azure.Management.Automation;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Model
23+
{
24+
/// <summary>
25+
/// The Job Stream.
26+
/// </summary>
27+
public class JobStreamRecord : JobStream
28+
{
29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="JobStreamRecord"/> class.
31+
/// </summary>
32+
/// <param name="jobStream">
33+
/// The job stream.
34+
/// </param>
35+
/// <param name="resourceGroupName">
36+
/// The resource group name.
37+
/// </param>
38+
/// <param name="automationAccountName">
39+
/// The automation account name
40+
/// </param>
41+
/// <param name="jobId">
42+
/// The job Id
43+
/// </param>
44+
/// <exception cref="System.ArgumentException">
45+
/// </exception>
46+
public JobStreamRecord(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId )
47+
{
48+
Requires.Argument("jobStream", jobStream).NotNull();
49+
50+
this.JobStreamId = jobStream.Properties.JobStreamId;
51+
this.Type = jobStream.Properties.StreamType;
52+
this.Time = jobStream.Properties.Time;
53+
this.AutomationAccountName = automationAccountName;
54+
this.ResourceGroupName = resourceGroupName;
55+
this.Id = jobId;
56+
57+
if (!String.IsNullOrWhiteSpace(jobStream.Properties.Summary))
58+
{
59+
this.Summary = jobStream.Properties.Summary.Length > Constants.JobSummaryLength ?
60+
jobStream.Properties.Summary.Substring(0, Constants.JobSummaryLength) + "..." :
61+
jobStream.Properties.Summary;
62+
}
63+
64+
this.Value = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
65+
foreach (var kvp in jobStream.Properties.Value)
66+
{
67+
object paramValue;
68+
try
69+
{
70+
paramValue = ((object)PowerShellJsonConverter.Deserialize(kvp.Value.ToString()));
71+
}
72+
catch (CmdletInvocationException exception)
73+
{
74+
if (!exception.Message.Contains("Invalid JSON primitive"))
75+
throw;
76+
77+
paramValue = kvp.Value;
78+
}
79+
this.Value.Add(kvp.Key, paramValue);
80+
}
81+
82+
}
83+
84+
/// <summary>
85+
/// Initializes a new instance of the <see cref="JobStreamRecord"/> class.
86+
/// </summary>
87+
public JobStreamRecord()
88+
{
89+
}
90+
91+
/// <summary>
92+
/// Gets or sets the stream values.
93+
/// </summary>
94+
public Hashtable Value { get; set; }
95+
}
96+
}

0 commit comments

Comments
 (0)