Skip to content

Commit

Permalink
chore: Add fcli fod access-control list-roles command
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Oct 23, 2023
1 parent f259d41 commit d31c1f4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@CommandLine.Command(name = "access-control",
aliases = "ac",
subcommands = {
FoDRoleListCommand.class,
FoDGroupListCommand.class,
FoDGroupGetCommand.class,
FoDGroupCreateCommand.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ fcli.fod.rest.lookup.<type>[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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d31c1f4

Please sign in to comment.