Skip to content

Commit 9d18281

Browse files
committed
Update PSCustomLogDataSourceProperties.cs
1 parent 758e2fd commit 9d18281

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

src/OperationalInsights/OperationalInsights/Models/DataSourcePropertiesPerKind/PSCustomLogDataSourceProperties.cs

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class Location
6565
/// <summary>
6666
/// Gets or sets the file system locations.
6767
/// </summary>
68+
[JsonProperty(PropertyName = "fileSystemLocations")]
6869
public FileSystemLocations fileSystemLocations { get; set; }
6970

7071
#endregion
@@ -80,12 +81,14 @@ public class FileSystemLocations
8081
/// <summary>
8182
/// Gets or sets the linux file type log paths.
8283
/// </summary>
83-
public string[] linuxFileTypeLogPaths { get; set; }
84+
[JsonProperty(PropertyName = "linuxFileTypeLogPaths")]
85+
public string[] LinuxFileTypeLogPaths { get; set; }
8486

8587
/// <summary>
8688
/// Gets or sets the windows file type log paths.
8789
/// </summary>
88-
public string[] windowsFileTypeLogPaths { get; set; }
90+
[JsonProperty(PropertyName = "windowsFileTypeLogPaths")]
91+
public string[] WindowsFileTypeLogPaths { get; set; }
8992

9093
#endregion
9194
}
@@ -100,7 +103,8 @@ public class RecordDelimiter
100103
/// <summary>
101104
/// Gets or sets the regex delimiter.
102105
/// </summary>
103-
public RegexDelimiter regexDelimiter { get; set; }
106+
[JsonProperty(PropertyName = "regexDelimiter")]
107+
public RegexDelimiter RegexDelimiter { get; set; }
104108

105109
#endregion
106110
}
@@ -115,17 +119,20 @@ public class RegexDelimiter
115119
/// <summary>
116120
/// Gets or sets the match index.
117121
/// </summary>
118-
public int matchIndex { get; set; }
122+
[JsonProperty(PropertyName = "matchIndex")]
123+
public int MatchIndex { get; set; }
119124

120125
/// <summary>
121126
/// Gets or sets the numberd group.
122127
/// </summary>
123-
public string numberdGroup { get; set; }
128+
[JsonProperty(PropertyName = "numberdGroup")]
129+
public string NumberdGroup { get; set; }
124130

125131
/// <summary>
126132
/// Gets or sets the pattern.
127133
/// </summary>
128-
public string pattern { get; set; }
134+
[JsonProperty(PropertyName = "pattern")]
135+
public string Pattern { get; set; }
129136

130137
#endregion
131138
}
@@ -140,12 +147,14 @@ public class CustomLogInput
140147
/// <summary>
141148
/// Gets or sets the location.
142149
/// </summary>
143-
public Location location { get; set; }
150+
[JsonProperty(PropertyName = "location")]
151+
public Location Location { get; set; }
144152

145153
/// <summary>
146154
/// Gets or sets the record delimiter.
147155
/// </summary>
148-
public RecordDelimiter recordDelimiter { get; set; }
156+
[JsonProperty(PropertyName = "recordDelimiter")]
157+
public RecordDelimiter RecordDelimiter { get; set; }
149158

150159
#endregion
151160
}
@@ -160,19 +169,28 @@ public class DateTimeExtraction
160169
/// <summary>
161170
/// Gets or sets the join string regex.
162171
/// </summary>
163-
public string joinStringRegex { get; set; }
172+
[JsonProperty("joinStringRegex")]
173+
public string JoinStringRegex { get; set; }
174+
175+
/// <summary>
176+
/// Gets or sets the regex string.
177+
/// </summary>
178+
[JsonIgnore]
179+
public string Regex { get; set; }
164180

165181
/// <summary>
166182
/// Gets or sets the regex.
167183
/// </summary>
168-
[CmdletParameterBreakingChange(nameof(regex), OldParamaterType = typeof(string), NewParameterTypeName = nameof(RegexDelimiter))]
184+
[CmdletParameterBreakingChange(nameof(Regex), OldParamaterType = typeof(string), NewParameterTypeName = nameof(RegexDelimiter))]
169185
[JsonConverter(typeof(RegexDelimiterJsonConverter))]
170-
public RegexDelimiter[] regex { get; set; }
186+
[JsonProperty("regex")]
187+
public RegexDelimiter[] RegexDelimiters { get; set; }
171188

172189
///<summary>
173190
/// Gets or sets the FormatString
174191
/// </summary>
175-
public string formatString { get; set; }
192+
[JsonProperty("formatString")]
193+
public string FormatString { get; set; }
176194

177195
#endregion
178196
}
@@ -187,7 +205,8 @@ public class ExtractionProperties
187205
/// <summary>
188206
/// Gets or sets the date time extraction.
189207
/// </summary>
190-
public DateTimeExtraction dateTimeExtraction { get; set; }
208+
[JsonProperty(PropertyName = "dateTimeExtraction")]
209+
public DateTimeExtraction DateTimeExtraction { get; set; }
191210

192211
#endregion
193212
}
@@ -202,21 +221,25 @@ public class CustomLogExtraction
202221
/// <summary>
203222
/// Gets or sets the extraction name.
204223
/// </summary>
205-
public string extractionName { get; set; }
224+
[JsonProperty(PropertyName = "extractionName")]
225+
public string ExtractionName { get; set; }
206226

207227
/// <summary>
208228
/// Gets or sets the extraction properties.
209229
/// </summary>
210-
public ExtractionProperties extractionProperties { get; set; }
230+
[JsonProperty(PropertyName = "extractionProperties")]
231+
public ExtractionProperties ExtractionProperties { get; set; }
211232

212233
/// <summary>
213234
/// Gets or sets the extraction type.
214235
/// </summary>
215-
public string extractionType { get; set; }
236+
[JsonProperty(PropertyName = "extractionType")]
237+
public string ExtractionType { get; set; }
216238

217239
#endregion
218240
}
219241

242+
// This converter allows backward compatibility
220243
public class RegexDelimiterJsonConverter : JsonConverter
221244
{
222245
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
@@ -227,11 +250,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
227250
JToken token = JToken.Load(reader);
228251
return token.ToObject<RegexDelimiter[]>();
229252
case JsonToken.String:
230-
// Allow input of just regex string for backward compatibility
231-
return new[] {new RegexDelimiter {matchIndex = 0, pattern = (string) reader.Value}};
253+
// Satisfy case in which user uses the old regex property in input
254+
return new[] {new RegexDelimiter {MatchIndex = 0, Pattern = (string) reader.Value}};
255+
default:
256+
throw new JsonSerializationException();
232257
}
233-
234-
throw new JsonSerializationException();
235258
}
236259

237260
public override bool CanWrite => false;

0 commit comments

Comments
 (0)