Search in sources :

Example 1 with RichGroup

use of cz.metacentrum.perun.openapi.model.RichGroup 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());
                }
            }
        }
    }
}
Also used : RichGroup(cz.metacentrum.perun.openapi.model.RichGroup) Group(cz.metacentrum.perun.openapi.model.Group) Attribute(cz.metacentrum.perun.openapi.model.Attribute) RichGroup(cz.metacentrum.perun.openapi.model.RichGroup)

Aggregations

Attribute (cz.metacentrum.perun.openapi.model.Attribute)1 Group (cz.metacentrum.perun.openapi.model.Group)1 RichGroup (cz.metacentrum.perun.openapi.model.RichGroup)1