Skip to content

Commit

Permalink
[HHQ-3768] Add --id and --name options to the group list CLI command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Morgan committed Mar 8, 2010
1 parent fea2fa5 commit c10564f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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.

Expand Down
20 changes: 20 additions & 0 deletions src/org/hyperic/hq/hqapi1/tools/GroupCommand.java
Expand Up @@ -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);

Expand All @@ -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();
}
Expand Down

0 comments on commit c10564f

Please sign in to comment.