From 7a83d561fc0cadaa5b2386b1ef90c8c0eb55c69c Mon Sep 17 00:00:00 2001 From: zkemppel-InRule <166459683+zkemppel-InRule@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:24:24 -0400 Subject: [PATCH 1/5] Added options to apply or remove labels from source rule app --- .../PromoteRuleApp/Program.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs index 34a2e3b..71ead12 100644 --- a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs +++ b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs @@ -1,6 +1,7 @@ using InRule.Repository.Client; using InRule.Repository; using System; +using InRule.Repository.Service.Data; using Mono.Options; using InRule.Runtime; @@ -14,8 +15,10 @@ static int Main(string[] args) bool showHelp = false; string ruleAppName = null; - string label = "LIVE"; - string comment = ""; + string label = null; + string comment = null; + string applyLabelToSource = null; + string removeLabelFromSource = null; string sourceCatalogUrl = null; string sourceCatalogUsername = null; @@ -30,6 +33,8 @@ static int Main(string[] args) { "n|RuleAppName=", "The name of the Rule App to promote.", n => ruleAppName = n }, { "l|Label=", "Label assigned to the desired version of the Rule App.", l => label = l }, { "m|Comment=", "Comment to be associated with the promotion commit.", c => comment = c }, + { "g|ApplyLabelToSource=", "Label to apply to source Rule App", l => applyLabelToSource = l }, + { "j|RemoveLabelFromSource=", "Label to remove from source Rule App", j => removeLabelFromSource = j}, //Source { "a|SrcCatUri=", "Web URI for the source IrCatalog Service endpoint.", c => sourceCatalogUrl = c }, { "b|SrcCatUser=", "IrCatalog Username for authentication .", u => sourceCatalogUsername = u }, @@ -64,19 +69,20 @@ static int Main(string[] args) } else { + var sourceCatCon = new RuleCatalogConnection(new Uri(sourceCatalogUrl), TimeSpan.FromSeconds(60), sourceCatalogUsername, sourceCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); + RuleApplicationDef sourceRuleAppDef = null; try { - CatalogRuleApplicationReference sourceRuleApp; if (string.IsNullOrEmpty(label)) { - sourceRuleApp = new CatalogRuleApplicationReference(sourceCatalogUrl, ruleAppName, sourceCatalogUsername, sourceCatalogPassword); + sourceRuleAppDef = sourceCatCon.GetLatestRuleAppRevision(ruleAppName); } else { - sourceRuleApp = new CatalogRuleApplicationReference(sourceCatalogUrl, ruleAppName, sourceCatalogUsername, sourceCatalogPassword, label); + var sourceRuleAppRef = sourceCatCon.GetRuleAppRef(ruleAppName); + sourceRuleAppDef = sourceCatCon.GetRuleAppByLabel(sourceRuleAppRef.Guid, label); } - sourceRuleAppDef = sourceRuleApp.GetRuleApplicationDef(); } catch (Exception ex) { @@ -88,8 +94,20 @@ static int Main(string[] args) { if (sourceRuleAppDef != null) { - var destCatCon = new RuleCatalogConnection(new Uri(destCatalogUrl), TimeSpan.FromSeconds(60), destCatalogUsername, destCatalogPassword); - var promotedDef = destCatCon.PromoteRuleApplication(sourceRuleAppDef, comment); + var destCatCon = new RuleCatalogConnection(new Uri(destCatalogUrl), TimeSpan.FromSeconds(60), destCatalogUsername, destCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); + + destCatCon.PromoteRuleApplication(sourceRuleAppDef, comment); + + if (!string.IsNullOrEmpty(applyLabelToSource)) + { + sourceCatCon.ApplyLabel(sourceRuleAppDef, applyLabelToSource); + } + + if (!string.IsNullOrEmpty(removeLabelFromSource)) + { + sourceCatCon.RemoveLabel(sourceRuleAppDef.Guid, removeLabelFromSource); + } + Console.WriteLine("Success!"); return 0; } From b8ba983b2b46088a8817e803dedc07c260fc3562 Mon Sep 17 00:00:00 2001 From: zkemppel-InRule <166459683+zkemppel-InRule@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:51:53 -0400 Subject: [PATCH 2/5] additional error handling --- .../PromoteRuleApp/Program.cs | 80 +++++++++++++------ 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs index 71ead12..9ad048b 100644 --- a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs +++ b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs @@ -69,7 +69,28 @@ static int Main(string[] args) } else { - var sourceCatCon = new RuleCatalogConnection(new Uri(sourceCatalogUrl), TimeSpan.FromSeconds(60), sourceCatalogUsername, sourceCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); + RuleCatalogConnection sourceCatCon = null; + RuleCatalogConnection destCatCon = null; + + try + { + sourceCatCon = new RuleCatalogConnection(new Uri(sourceCatalogUrl), TimeSpan.FromSeconds(60), sourceCatalogUsername, sourceCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); + } + catch (Exception ex) + { + Console.WriteLine("Error connecting to source catalog: " + ex.Message); + return 1; + } + + try + { + destCatCon = new RuleCatalogConnection(new Uri(destCatalogUrl), TimeSpan.FromSeconds(60), destCatalogUsername, destCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); + } + catch (Exception ex) + { + Console.WriteLine("Error connecting to destination catalog: " + ex.Message); + return 1; + } RuleApplicationDef sourceRuleAppDef = null; try @@ -83,6 +104,13 @@ static int Main(string[] args) var sourceRuleAppRef = sourceCatCon.GetRuleAppRef(ruleAppName); sourceRuleAppDef = sourceCatCon.GetRuleAppByLabel(sourceRuleAppRef.Guid, label); } + + if (sourceRuleAppDef == null) + { + Console.WriteLine("Source Rule App was unable to be retrieved."); + return 1; + } + } catch (Exception ex) { @@ -92,36 +120,42 @@ static int Main(string[] args) try { - if (sourceRuleAppDef != null) - { - var destCatCon = new RuleCatalogConnection(new Uri(destCatalogUrl), TimeSpan.FromSeconds(60), destCatalogUsername, destCatalogPassword, RuleCatalogAuthenticationType.BuiltIn); - - destCatCon.PromoteRuleApplication(sourceRuleAppDef, comment); - - if (!string.IsNullOrEmpty(applyLabelToSource)) - { - sourceCatCon.ApplyLabel(sourceRuleAppDef, applyLabelToSource); - } - - if (!string.IsNullOrEmpty(removeLabelFromSource)) - { - sourceCatCon.RemoveLabel(sourceRuleAppDef.Guid, removeLabelFromSource); - } + destCatCon.PromoteRuleApplication(sourceRuleAppDef, comment); + } + catch (Exception ex) + { + Console.WriteLine("Error promoting Rule App: " + ex.Message); + return 1; + } - Console.WriteLine("Success!"); - return 0; + if (!string.IsNullOrEmpty(applyLabelToSource)) + { + try + { + sourceCatCon.ApplyLabel(sourceRuleAppDef, applyLabelToSource); } - else + catch (Exception ex) { - Console.WriteLine("Source Rule App was unable to be retrieved."); + Console.WriteLine("Error applying label to source rule app: " + ex.Message); return 1; } } - catch (Exception ex) + + if (!string.IsNullOrEmpty(removeLabelFromSource)) { - Console.WriteLine("Error promoting Rule App: " + ex.Message); - return 1; + try + { + sourceCatCon.RemoveLabel(sourceRuleAppDef.Guid, removeLabelFromSource); + } + catch (Exception ex) + { + Console.WriteLine("Error removing label from source rule app: " + ex.Message); + return 1; + } } + + Console.WriteLine("Success!"); + return 0; } } From 8bf1f14d1948dd7c6e499e80e30c6d0553515683 Mon Sep 17 00:00:00 2001 From: zkemppel-InRule <166459683+zkemppel-InRule@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:53:42 -0400 Subject: [PATCH 3/5] remove unused dependencies --- Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs index 9ad048b..14da7fa 100644 --- a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs +++ b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs @@ -1,9 +1,7 @@ using InRule.Repository.Client; using InRule.Repository; using System; -using InRule.Repository.Service.Data; using Mono.Options; -using InRule.Runtime; namespace PromoteRuleApp From 1d46cb5f995973400562de4e2add8018b9c8a11e Mon Sep 17 00:00:00 2001 From: zkemppel-InRule <166459683+zkemppel-InRule@users.noreply.github.com> Date: Tue, 23 Jun 2026 17:07:01 -0400 Subject: [PATCH 4/5] messaging consistency --- .../CommandLineTools/PromoteRuleApp/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs index 14da7fa..d5af1cf 100644 --- a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs +++ b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs @@ -31,11 +31,11 @@ static int Main(string[] args) { "n|RuleAppName=", "The name of the Rule App to promote.", n => ruleAppName = n }, { "l|Label=", "Label assigned to the desired version of the Rule App.", l => label = l }, { "m|Comment=", "Comment to be associated with the promotion commit.", c => comment = c }, - { "g|ApplyLabelToSource=", "Label to apply to source Rule App", l => applyLabelToSource = l }, - { "j|RemoveLabelFromSource=", "Label to remove from source Rule App", j => removeLabelFromSource = j}, + { "g|ApplyLabelToSource=", "Label to apply to source Rule App.", l => applyLabelToSource = l }, + { "j|RemoveLabelFromSource=", "Label to remove from source Rule App.", j => removeLabelFromSource = j}, //Source { "a|SrcCatUri=", "Web URI for the source IrCatalog Service endpoint.", c => sourceCatalogUrl = c }, - { "b|SrcCatUser=", "IrCatalog Username for authentication .", u => sourceCatalogUsername = u }, + { "b|SrcCatUser=", "IrCatalog Username for authentication.", u => sourceCatalogUsername = u }, { "c|SrcCatPass=", "IrCatalog Password for authentication.", p => sourceCatalogPassword = p }, //Dest { "d|DestCatUri=", "Web URI for the target IrCatalog Service endpoint.", c => destCatalogUrl = c }, @@ -134,7 +134,7 @@ static int Main(string[] args) } catch (Exception ex) { - Console.WriteLine("Error applying label to source rule app: " + ex.Message); + Console.WriteLine("Error applying label to source Rule App: " + ex.Message); return 1; } } @@ -147,7 +147,7 @@ static int Main(string[] args) } catch (Exception ex) { - Console.WriteLine("Error removing label from source rule app: " + ex.Message); + Console.WriteLine("Error removing label from source Rule App: " + ex.Message); return 1; } } From 554c49fd3ae0f60f5b2aaf8fa99b57649aaf0eac Mon Sep 17 00:00:00 2001 From: zkemppel-InRule <166459683+zkemppel-InRule@users.noreply.github.com> Date: Tue, 23 Jun 2026 17:09:52 -0400 Subject: [PATCH 5/5] copilot being pedantic --- Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs index d5af1cf..d332c57 100644 --- a/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs +++ b/Developer Samples/CommandLineTools/PromoteRuleApp/Program.cs @@ -164,6 +164,7 @@ private static void ShowHelp(OptionSet p) Console.WriteLine("Promotes a Rule Application from one catalog into another."); Console.WriteLine(); Console.WriteLine("All requests must contain RuleAppName and connection information for both source and destination Catalogs."); + Console.WriteLine("Omitting -Label will result in the latest Rule App revision being promoted."); Console.WriteLine(); Console.WriteLine("Options:"); p.WriteOptionDescriptions(Console.Out);