Skip to content

Commit

Permalink
Merge branch 'hqapi-2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Morgan committed Jul 14, 2009
2 parents 7aca76e + ce38d81 commit fcddd4b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -9,6 +9,10 @@ Changes in HQApi 3.0

Changes in HQApi 2.2

*) [HHQ-3230] Add --conditionTypeExclude to allow definitions to be excluded
based on conditions. As part of this change --conditionType has been
renamed to --conditionTypeInclude

Changes in HQApi 2.1

*) [HHQ-3230] Add --conditionCount and --conditionType parameters to
Expand Down
31 changes: 25 additions & 6 deletions src/org/hyperic/hq/hqapi1/tools/AlertDefinitionCommand.java
Expand Up @@ -63,7 +63,8 @@ public class AlertDefinitionCommand extends Command {
private static String OPT_BATCH_SIZE = "batchSize";
private static String OPT_ESCLATION = "escalation";
private static String OPT_COND_COUNT = "conditionCount";
private static String OPT_COND_TYPE = "conditionType";
private static String OPT_COND_INCLUDE = "conditionTypeInclude";
private static String OPT_COND_EXCLUDE = "conditionTypeExclude";

private void printUsage() {
System.err.println("One of " + Arrays.toString(COMMANDS) + " required");
Expand Down Expand Up @@ -115,9 +116,13 @@ private void list(String[] args) throws Exception {
"which have the number of conditions " +
"specified")
.withRequiredArg().ofType(Integer.class);
p.accepts(OPT_COND_TYPE, "If specified, only show alert definitions " +
"which have at least one condition of the " +
"given type")
p.accepts(OPT_COND_INCLUDE, "If specified, only show alert definitions " +
"which have at least one condition of the " +
"given type")
.withRequiredArg().ofType(Integer.class);
p.accepts(OPT_COND_EXCLUDE, "If specified, exclude alert definitions " +
"which have at least one condition of the " +
"given type")
.withRequiredArg().ofType(Integer.class);

OptionSet options = getOptions(p, args);
Expand Down Expand Up @@ -176,8 +181,8 @@ private void list(String[] args) throws Exception {
}
}

if (options.has(OPT_COND_TYPE)) {
Integer type = (Integer)getRequired(options, OPT_COND_TYPE);
if (options.has(OPT_COND_INCLUDE)) {
Integer type = (Integer)getRequired(options, OPT_COND_INCLUDE);
for (Iterator<AlertDefinition> i =
alertDefs.getAlertDefinition().iterator(); i.hasNext(); ) {
AlertDefinition d = i.next();
Expand All @@ -193,6 +198,20 @@ private void list(String[] args) throws Exception {
}
}

if (options.has(OPT_COND_EXCLUDE)) {
Integer type = (Integer)getRequired(options, OPT_COND_EXCLUDE);
for (Iterator<AlertDefinition> i =
alertDefs.getAlertDefinition().iterator(); i.hasNext(); ) {
AlertDefinition d = i.next();
for (AlertCondition c : d.getAlertCondition()) {
if (c.getType() == type) {
i.remove();
break;
}
}
}
}

checkSuccess(alertDefs);
XmlUtil.serialize(alertDefs, System.out, Boolean.TRUE);
}
Expand Down

0 comments on commit fcddd4b

Please sign in to comment.