use of cz.metacentrum.perun.openapi.model.Group in project perun by CESNET.
the class ListOfFacilityGroups method executeCommand.
@Override
public void executeCommand(PerunCLI.CommandContext ctx) {
int facilityId = this.getFacilityId(ctx, true);
Integer voId = this.getVoId(ctx, false);
Integer serviceId = this.getServiceId(ctx, false);
String[] optionA = ctx.getCommandLine().getOptionValues("a");
if (optionA == null) {
List<Group> groups = ctx.getPerunRPC().getFacilitiesManager().getAllowedGroups(facilityId, voId, serviceId);
this.sort(ctx, groups, Comparator.comparing(Group::getName));
for (Group group : groups) {
System.out.println(group.getId() + "\t" + group.getName() + "\t" + "\"" + group.getDescription() + "\"\t voId: " + group.getVoId());
}
} else {
List<String> attrNames = Arrays.asList(optionA);
List<RichGroup> groups = ctx.getPerunRPC().getFacilitiesManager().getAllowedRichGroupsWithAttributes(facilityId, attrNames, voId, serviceId);
this.sort(ctx, groups, Comparator.comparing(RichGroup::getName));
for (RichGroup group : groups) {
System.out.println(group.getId() + "\t" + group.getName() + "\t" + "\"" + group.getDescription() + "\"\t voId: " + group.getVoId());
List<Attribute> groupAttributes = group.getAttributes();
if (groupAttributes != null) {
for (Attribute a : groupAttributes) {
System.out.println(" " + a.getNamespace() + ":" + a.getFriendlyName() + " = " + a.getValue());
}
}
}
}
}