Skip to content

Commit

Permalink
fix(automate): add success object level (#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdriesler authored Nov 26, 2024
2 parents b5c5712 + f706e24 commit 6354863
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Automate/Speckle.Automate.Sdk/AutomationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ public void AttachInfoToObjects(
Dictionary<string, object>? visualOverrides = null
) => AttachResultToObjects(ObjectResultLevel.Info, category, objectIds, message, metadata, visualOverrides);

/// <summary>
/// Add a new success case to the run results.
/// If the success cause has already created a success case,
/// the case will be extended with a new case referring to the causing objects.
/// </summary>
/// <inheritdoc cref="AttachErrorToObjects"/>
public void AttachSuccessToObjects(
string category,
IEnumerable<string> objectIds,
string? message = null,
Dictionary<string, object>? metadata = null,
Dictionary<string, object>? visualOverrides = null
) => AttachResultToObjects(ObjectResultLevel.Success, category, objectIds, message, metadata, visualOverrides);

/// <summary>
/// Add a new case to the run results.
/// If the cause has already created an case with equal level,
Expand Down
1 change: 1 addition & 0 deletions Automate/Speckle.Automate.Sdk/Schema/ObjectResultLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Speckle.Automate.Sdk.Schema;

public enum ObjectResultLevel
{
Success,
Info,
Warning,
Error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Speckle.Automate.Sdk.Schema;

public abstract class ObjectResultLevelMapping
{
private const string SUCCESS = "SUCCESS";
private const string INFO = "INFO";
private const string WARNING = "WARNING";
private const string ERROR = "ERROR";
Expand All @@ -12,6 +13,7 @@ public static string Get(ObjectResultLevel level) =>
ObjectResultLevel.Error => ERROR,
ObjectResultLevel.Warning => WARNING,
ObjectResultLevel.Info => INFO,
ObjectResultLevel.Success => SUCCESS,
_ => throw new ArgumentOutOfRangeException($"Not valid value for enum {level}")
};
}

0 comments on commit 6354863

Please sign in to comment.