Skip to content

Commit

Permalink
fix: use 'object' as default classification (#138)
Browse files Browse the repository at this point in the history
The REST API operations that return collections of objects include a
classification property. Many nodes in the tree come back with a value
of "" for this property. However those nodes should be classified with
"object" instead. This is being resolved in the REST API; however this
commit addresses the issue when this client is used with older
unpatched Metasys devices.
  • Loading branch information
michaelgwelch authored Jul 23, 2024
1 parent 26417a0 commit 18bdffd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions MetasysServices/Models/MetasysObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public MetasysObject() { }
/// Classification of the object
/// </summary>
public string Classification { get; set; }
private const string DefaultClassification = "object";

internal MetasysObject(JToken token, ApiVersion version, IEnumerable<MetasysObject> children = null, MetasysObjectTypeEnum? type =null)
{
Expand Down Expand Up @@ -187,11 +188,19 @@ internal MetasysObject(JToken token, ApiVersion version, IEnumerable<MetasysObje
}
try
{
Classification = jobj.ContainsKey("classification") ? token["classification"].Value<string>() : null;
if (jobj.ContainsKey("classification"))
{
var tokenValue = token["classification"].Value<string>().Trim();
Classification = tokenValue == string.Empty ? DefaultClassification : tokenValue;
}
else
{
Classification = DefaultClassification;
}
}
catch
{
Classification = null;
Classification = DefaultClassification;
}
}

Expand Down

0 comments on commit 18bdffd

Please sign in to comment.