Skip to content

Commit 01eca3f

Browse files
committed
list roles and users
1 parent 7146b6e commit 01eca3f

34 files changed

+462
-238
lines changed

astra-shell/src/main/java/com/datastax/astra/shell/AstraCli.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
import com.datastax.astra.shell.cmd.config.ConfigList;
1010
import com.datastax.astra.shell.cmd.config.ConfigShow;
1111
import com.datastax.astra.shell.cmd.config.Setup;
12-
import com.datastax.astra.shell.cmd.db.Db;
1312
import com.datastax.astra.shell.cmd.db.DbCreateCli;
1413
import com.datastax.astra.shell.cmd.db.DbDeleteCli;
1514
import com.datastax.astra.shell.cmd.db.DbListCli;
15+
import com.datastax.astra.shell.cmd.db.OperationsDb;
16+
import com.datastax.astra.shell.cmd.iam.RoleListCli;
17+
import com.datastax.astra.shell.cmd.iam.RoleShowCli;
18+
import com.datastax.astra.shell.cmd.iam.UserListCli;
1619
import com.datastax.astra.shell.cmd.shell.ShellCommand;
1720
import com.datastax.astra.shell.utils.LoggerShell;
1821
import com.github.rvesse.airline.annotations.Cli;
@@ -34,7 +37,7 @@
3437
ShellCommand.class
3538
},
3639
groups = {
37-
@Group(name = Db.DB, description = "Commands acting of database", commands = {
40+
@Group(name = OperationsDb.DB, description = "Commands acting of database", commands = {
3841
DbCreateCli.class,
3942
DbDeleteCli.class,
4043
DbListCli.class
@@ -45,8 +48,21 @@
4548
ConfigDelete.class,
4649
ConfigShow.class,
4750
ConfigList.class
48-
}
49-
),
51+
}),
52+
@Group(name= "role", description = "Manage the roles (RBAC)", commands = {
53+
RoleListCli.class,
54+
RoleShowCli.class
55+
}),
56+
@Group(name= "user", description = "Manage the users permissions", commands = {
57+
UserListCli.class
58+
}),
59+
@Group(name= "token", description = "Manage the security tokens", commands = {
60+
61+
}),
62+
@Group(name= "acl", description = "Manage the access lists", commands = {
63+
64+
})
65+
5066
})
5167
public class AstraCli {
5268

astra-shell/src/main/java/com/datastax/astra/shell/AstraShell.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import com.datastax.astra.shell.cmd.ExitCommand;
44
import com.datastax.astra.shell.cmd.HelpCommand;
55
import com.datastax.astra.shell.cmd.QuitCommand;
6-
import com.datastax.astra.shell.cmd.db.Db;
76
import com.datastax.astra.shell.cmd.db.DbCreateShell;
87
import com.datastax.astra.shell.cmd.db.DbDeleteShell;
98
import com.datastax.astra.shell.cmd.db.DbListShell;
9+
import com.datastax.astra.shell.cmd.db.OperationsDb;
10+
import com.datastax.astra.shell.cmd.iam.RoleListShell;
11+
import com.datastax.astra.shell.cmd.iam.RoleShowCli;
12+
import com.datastax.astra.shell.cmd.iam.UserListShell;
1013
import com.datastax.astra.shell.cmd.shell.ConnectCommand;
1114
import com.datastax.astra.shell.cmd.shell.CqlShCommand;
1215
import com.datastax.astra.shell.cmd.shell.EmptyCommand;
@@ -35,18 +38,21 @@
3538
CqlShCommand.class
3639
},
3740
groups = {
38-
@Group(name = Db.DB, description = "Commands acting of database", commands = {
41+
@Group(name = OperationsDb.DB, description = "Commands acting of database", commands = {
3942
DbCreateShell.class,
4043
DbDeleteShell.class,
4144
DbListShell.class
4245
}),
43-
@Group(
44-
name = "use",
45-
description = "Focus on an entity (context & prompt changed)",
46-
commands = {
47-
UseDb.class
48-
}
49-
)
46+
@Group(name= "role", description = "Manage the roles (RBAC)", commands = {
47+
RoleListShell.class,
48+
RoleShowCli.class
49+
}),
50+
@Group(name= "user", description = "Manage the users permission", commands = {
51+
UserListShell.class
52+
}),
53+
@Group(name = "use", description = "Focus on an entity (context & prompt changed)", commands = {
54+
UseDb.class
55+
}),
5056
})
5157
public class AstraShell {
5258

astra-shell/src/main/java/com/datastax/astra/shell/ExitCode.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public enum ExitCode {
2323
PARSE_ERROR(-1),
2424

2525
/** code. */
26-
CANNOT_CONNECT(408);
26+
CANNOT_CONNECT(408),
27+
28+
/** Internal error. */
29+
INTERNAL_ERROR(500);
2730

2831
/* Exit code. */
2932
private int code;

astra-shell/src/main/java/com/datastax/astra/shell/cmd/BaseCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import java.util.Map;
55
import java.util.HashMap;
66

7-
import com.datastax.astra.shell.CsvOutput;
87
import com.datastax.astra.shell.ExitCode;
9-
import com.datastax.astra.shell.JsonOutput;
10-
import com.datastax.astra.shell.OutputFormat;
8+
import com.datastax.astra.shell.output.CsvOutput;
9+
import com.datastax.astra.shell.output.JsonOutput;
10+
import com.datastax.astra.shell.output.OutputFormat;
1111
import com.datastax.astra.shell.utils.LoggerShell;
1212
import com.github.rvesse.airline.annotations.Option;
1313

@@ -60,7 +60,7 @@ public void outputError(ExitCode code, String msg) {
6060
LoggerShell.json(new JsonOutput(code, code.name() + ": " + msg));
6161
break;
6262
case csv:
63-
LoggerShell.csv(new CsvOutput(code.getCode(), code.name() + ": " + msg));
63+
LoggerShell.csv(new CsvOutput(code, code.name() + ": " + msg));
6464
break;
6565
case human:
6666
default:
@@ -104,7 +104,7 @@ public void outputSuccess(String msg) {
104104
LoggerShell.json(new JsonOutput(ExitCode.SUCCESS, msg));
105105
break;
106106
case csv:
107-
LoggerShell.csv(new CsvOutput(ExitCode.SUCCESS.getCode(), msg));
107+
LoggerShell.csv(new CsvOutput(ExitCode.SUCCESS, msg));
108108
break;
109109
case human:
110110
default:

astra-shell/src/main/java/com/datastax/astra/shell/cmd/config/Setup.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.fusesource.jansi.Ansi.Color;
99

1010
import com.datastax.astra.sdk.organizations.OrganizationsClient;
11-
import com.datastax.astra.shell.cmd.show.ShowConfigsCommand;
1211
import com.datastax.astra.shell.utils.LoggerShell;
1312
import com.datastax.astra.shell.utils.ShellPrinter;
1413
import com.github.rvesse.airline.annotations.Command;
@@ -58,7 +57,7 @@ public void run() {
5857
ccc.run();
5958
valid_token = true;
6059

61-
ShowConfigsCommand configs = new ShowConfigsCommand();
60+
ConfigShow configs = new ConfigShow();
6261
configs.astraRc = this.astraRc;
6362
configs.configFilename = this.configFilename;
6463
configs.run();
@@ -70,7 +69,7 @@ public void run() {
7069
}
7170

7271
LoggerShell.println("\n[What's NEXT ?]\n", Ansi.Color.CYAN);
73-
System.out.println("You are all set you can now:");
72+
System.out.println("You are all set. You can now:");
7473
System.out.println(" • Use any command, 'astra help' will get you the list");
7574
System.out.println(" • Try with 'astra db list'");
7675
System.out.println(" • Enter interactive mode using 'astra'");

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/DbCreateCli.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class DbCreateCli extends BaseCliCommand {
3030
*/
3131
@Option(name = { "-r", "--region" }, title = "DB_REGION", arity = 1,
3232
description = "Cloud provider region to provision")
33-
protected String databaseRegion = Db.DEFAULT_REGION;
33+
protected String databaseRegion = OperationsDb.DEFAULT_REGION;
3434

3535
/**
3636
* Default keyspace created with the Db
@@ -42,7 +42,7 @@ public class DbCreateCli extends BaseCliCommand {
4242
/** {@inheritDoc} */
4343
@Override
4444
public ExitCode execute() {
45-
return Db.createDb(this, databaseName, databaseRegion, defaultKeyspace);
45+
return OperationsDb.createDb(this, databaseName, databaseRegion, defaultKeyspace);
4646
}
4747

4848
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/DbCreateShell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class DbCreateShell extends BaseShellCommand {
3030
*/
3131
@Option(name = { "-r", "--region" }, title = "DB_REGION", arity = 1,
3232
description = "Cloud provider region to provision")
33-
protected String databaseRegion = Db.DEFAULT_REGION;
33+
protected String databaseRegion = OperationsDb.DEFAULT_REGION;
3434

3535
/**
3636
* Default keyspace created with the Db
@@ -42,7 +42,7 @@ public class DbCreateShell extends BaseShellCommand {
4242
/** {@inheritDoc} */
4343
@Override
4444
public ExitCode execute() {
45-
return Db.createDb(this, databaseName, databaseRegion, defaultKeyspace);
45+
return OperationsDb.createDb(this, databaseName, databaseRegion, defaultKeyspace);
4646
}
4747

4848
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/DbDeleteCli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class DbDeleteCli extends BaseCliCommand {
2424

2525
/** {@inheritDoc} */
2626
public ExitCode execute() {
27-
return Db.deleteDb(this, databaseId);
27+
return OperationsDb.deleteDb(this, databaseId);
2828
}
2929

3030
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/DbDeleteShell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class DbDeleteShell extends BaseShellCommand {
2424

2525
/** {@inheritDoc} */
2626
public ExitCode execute() {
27-
return Db.deleteDb(this, databaseId);
27+
return OperationsDb.deleteDb(this, databaseId);
2828
}
2929

3030
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/DbListCli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DbListCli extends BaseCliCommand {
1515

1616
/** {@inheritDoc} */
1717
public ExitCode execute() {
18-
return Db.listDb(this);
18+
return OperationsDb.listDb(this);
1919
}
2020

2121
}

0 commit comments

Comments
 (0)