From c10564fc606c249078eb789c0b08153c7b0a11ae Mon Sep 17 00:00:00 2001 From: Ryan Morgan Date: Mon, 8 Mar 2010 13:01:14 -0800 Subject: [PATCH] [HHQ-3768] Add --id and --name options to the group list CLI command. --- ChangeLog | 2 ++ .../hyperic/hq/hqapi1/tools/GroupCommand.java | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 58442da1..ce478635 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Changes in HQApi 2.4 + *) [HHQ-3768] Add --id and --name options to the group list CLI command. + *) [HHQ-3785] Add command lines options to alertdefinition sync command to allow for escalations and alert actions to be set and reset. diff --git a/src/org/hyperic/hq/hqapi1/tools/GroupCommand.java b/src/org/hyperic/hq/hqapi1/tools/GroupCommand.java index 0eaad664..b84632a3 100644 --- a/src/org/hyperic/hq/hqapi1/tools/GroupCommand.java +++ b/src/org/hyperic/hq/hqapi1/tools/GroupCommand.java @@ -104,6 +104,10 @@ private void list(String[] args) throws Exception { p.accepts(OPT_COMPAT, "List only compatible groups"); p.accepts(OPT_MIXED, "List only mixed groups"); + p.accepts(OPT_ID, "List group with the given id") + .withRequiredArg().ofType(Integer.class); + p.accepts(OPT_NAME, "Lit group with the given name") + .withRequiredArg().ofType(String.class); OptionSet options = getOptions(p, args); @@ -122,6 +126,22 @@ private void list(String[] args) throws Exception { groups = groupApi.getCompatibleGroups(); } else if (options.has(OPT_MIXED)) { groups = groupApi.getMixedGroups(); + } else if (options.has(OPT_ID)) { + // Wrap in a GroupsResponse to allow returned XML to be synced. + Integer id = (Integer)getRequired(options, OPT_ID); + GroupResponse groupResponse = groupApi.getGroup(id); + checkSuccess(groupResponse); + groups = new GroupsResponse(); + groups.setStatus(groupResponse.getStatus()); + groups.getGroup().add(groupResponse.getGroup()); + } else if (options.has(OPT_NAME)) { + // Wrap in a GroupsResponse to allow returned XML to be synced. + String name = (String)getRequired(options, OPT_NAME); + GroupResponse groupResponse = groupApi.getGroup(name); + checkSuccess(groupResponse); + groups = new GroupsResponse(); + groups.setStatus(groupResponse.getStatus()); + groups.getGroup().add(groupResponse.getGroup()); } else { groups = groupApi.getGroups(); }