diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDAccessControlCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDAccessControlCommands.java index 1a896a8c9e..ae273cb370 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDAccessControlCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDAccessControlCommands.java @@ -19,6 +19,7 @@ @CommandLine.Command(name = "access-control", aliases = "ac", subcommands = { + FoDRoleListCommand.class, FoDGroupListCommand.class, FoDGroupGetCommand.class, FoDGroupCreateCommand.class, diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDRoleListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDRoleListCommand.java new file mode 100644 index 0000000000..33688cb73c --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/access_control/cli/cmd/FoDRoleListCommand.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ +package com.fortify.cli.fod.access_control.cli.cmd; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fortify.cli.common.cli.util.CommandGroup; +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.common.output.transform.IRecordTransformer; +import com.fortify.cli.common.output.transform.fields.RenameFieldsTransformer; +import com.fortify.cli.common.variable.DefaultVariablePropertyName; +import com.fortify.cli.fod._common.output.cli.AbstractFoDBaseRequestOutputCommand; +import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod.rest.lookup.helper.FoDLookupType; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = "list-roles", aliases = "lsr") @CommandGroup("role") +@DefaultVariablePropertyName("id") +public class FoDRoleListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { + private static final RenameFieldsTransformer RECORD_TRANSFORMER = new RenameFieldsTransformer( + new String[] {"value:id", "text:name"}); + @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; + + @Override + public HttpRequest getBaseRequest(UnirestInstance unirest) { + return unirest.get(FoDUrls.LOOKUP_ITEMS).queryString("type", FoDLookupType.Roles.name()); + } + + @Override + public JsonNode transformRecord(JsonNode record) { + ((ObjectNode)record).remove("group"); + return RECORD_TRANSFORMER.transform(record); + } + + @Override + public boolean isSingular() { + return false; + } +} diff --git a/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties b/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties index f6cd5205e1..5988824b0c 100644 --- a/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties +++ b/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties @@ -149,6 +149,7 @@ fcli.fod.rest.lookup.[0] = The type of lookup items to return. Valid value ### For the "fod access-control" command ### fcli.fod.access-control.usage.header = Manage FoD users & groups. +fcli.fod.access-control.list-roles.usage.header = List user roles. fcli.fod.access-control.create-group.usage.header = Create a new user group. fcli.fod.access-control.create-group.name = The name of the user group. fcli.fod.access-control.create-group.add-all-users = Add all tenant users to the user group. @@ -161,7 +162,6 @@ fcli.fod.access-control.update-group.add-all-users = Add all tenant users to the fcli.fod.access-control.update-group.remove-all-users = Remove all tenant users from the user group. fcli.fod.access-control.group.output.header.assignedUsersCount = Assigned Users fcli.fod.access-control.group.output.header.assignedApplicationsCount = Assigned Applications - fcli.fod.access-control.create-user.usage.header = Create a new user. fcli.fod.access-control.create-user.user-name = The username of the user. fcli.fod.access-control.create-user.email = The email address of the user. @@ -578,6 +578,7 @@ fcli.env.default.prefix=FCLI_DEFAULT # Table output columns configuration fcli.fod.access-control.user.output.table.options = userId,userName,firstName,lastName,email,roleName fcli.fod.access-control.group.output.table.options = id,name,assignedUsersCount,assignedApplicationsCount +fcli.fod.access-control.role.output.table.options = id,name fcli.fod.app.output.table.options = applicationId,applicationName,fcliApplicationType,businessCriticalityType fcli.fod.app.scan.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName fcli.fod.microservice.output.table.options = microserviceId,microserviceName,applicationName