Skip to content

Commit 63f7026

Browse files
committed
CreateDb, Delete Db, Show User, Show Users, Show Rolem Show Roles
1 parent 19d8d79 commit 63f7026

21 files changed

+788
-305
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
package com.datastax.astra.sdk.databases.domain;
2+
3+
/**
4+
* Hold object returned by accessing servlerss list.
5+
*
6+
* @author Cedrick LUNVEN (@clunven)
7+
*/
8+
public class DatabaseRegionServerless {
9+
10+
/** Region Name. */
11+
private String name;
12+
13+
/** Cloud provider. */
14+
private String cloudProvider;
15+
16+
/** Name of the region picked. */
17+
private String displayName;
18+
19+
/** Zone. */
20+
private String zone;
21+
22+
/** Classification. */
23+
private String classification;
24+
25+
/** working region. */
26+
private boolean enabled;
27+
28+
/** limited ? */
29+
private boolean reservedForQualifiedUsers;
30+
31+
/**
32+
* Default Constructor.
33+
*/
34+
public DatabaseRegionServerless() {
35+
}
36+
37+
/**
38+
* Getter accessor for attribute 'name'.
39+
*
40+
* @return
41+
* current value of 'name'
42+
*/
43+
public String getName() {
44+
return name;
45+
}
46+
47+
/**
48+
* Setter accessor for attribute 'name'.
49+
* @param name
50+
* new value for 'name '
51+
*/
52+
public void setName(String name) {
53+
this.name = name;
54+
}
55+
56+
/**
57+
* Getter accessor for attribute 'cloudProvider'.
58+
*
59+
* @return
60+
* current value of 'cloudProvider'
61+
*/
62+
public String getCloudProvider() {
63+
return cloudProvider;
64+
}
65+
66+
/**
67+
* Setter accessor for attribute 'cloudProvider'.
68+
* @param cloudProvider
69+
* new value for 'cloudProvider '
70+
*/
71+
public void setCloudProvider(String cloudProvider) {
72+
this.cloudProvider = cloudProvider;
73+
}
74+
75+
/**
76+
* Getter accessor for attribute 'displayName'.
77+
*
78+
* @return
79+
* current value of 'displayName'
80+
*/
81+
public String getDisplayName() {
82+
return displayName;
83+
}
84+
85+
/**
86+
* Setter accessor for attribute 'displayName'.
87+
* @param displayName
88+
* new value for 'displayName '
89+
*/
90+
public void setDisplayName(String displayName) {
91+
this.displayName = displayName;
92+
}
93+
94+
/**
95+
* Getter accessor for attribute 'zone'.
96+
*
97+
* @return
98+
* current value of 'zone'
99+
*/
100+
public String getZone() {
101+
return zone;
102+
}
103+
104+
/**
105+
* Setter accessor for attribute 'zone'.
106+
* @param zone
107+
* new value for 'zone '
108+
*/
109+
public void setZone(String zone) {
110+
this.zone = zone;
111+
}
112+
113+
/**
114+
* Getter accessor for attribute 'classification'.
115+
*
116+
* @return
117+
* current value of 'classification'
118+
*/
119+
public String getClassification() {
120+
return classification;
121+
}
122+
123+
/**
124+
* Setter accessor for attribute 'classification'.
125+
* @param classification
126+
* new value for 'classification '
127+
*/
128+
public void setClassification(String classification) {
129+
this.classification = classification;
130+
}
131+
132+
/**
133+
* Getter accessor for attribute 'enabled'.
134+
*
135+
* @return
136+
* current value of 'enabled'
137+
*/
138+
public boolean isEnabled() {
139+
return enabled;
140+
}
141+
142+
/**
143+
* Setter accessor for attribute 'enabled'.
144+
* @param enabled
145+
* new value for 'enabled '
146+
*/
147+
public void setEnabled(boolean enabled) {
148+
this.enabled = enabled;
149+
}
150+
151+
/**
152+
* Getter accessor for attribute 'reservedForQualifiedUsers'.
153+
*
154+
* @return
155+
* current value of 'reservedForQualifiedUsers'
156+
*/
157+
public boolean isReservedForQualifiedUsers() {
158+
return reservedForQualifiedUsers;
159+
}
160+
161+
/**
162+
* Setter accessor for attribute 'reservedForQualifiedUsers'.
163+
* @param reservedForQualifiedUsers
164+
* new value for 'reservedForQualifiedUsers '
165+
*/
166+
public void setReservedForQualifiedUsers(boolean reservedForQualifiedUsers) {
167+
this.reservedForQualifiedUsers = reservedForQualifiedUsers;
168+
}
169+
170+
171+
172+
}

astra-sdk/src/main/java/com/datastax/astra/sdk/organizations/OrganizationsClient.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import com.datastax.astra.sdk.databases.domain.CloudProviderType;
1717
import com.datastax.astra.sdk.databases.domain.DatabaseRegion;
18+
import com.datastax.astra.sdk.databases.domain.DatabaseRegionServerless;
1819
import com.datastax.astra.sdk.organizations.domain.CreateRoleResponse;
1920
import com.datastax.astra.sdk.organizations.domain.CreateTokenResponse;
2021
import com.datastax.astra.sdk.organizations.domain.DefaultRoles;
@@ -50,6 +51,9 @@ public class OrganizationsClient {
5051
/** Get Available Regions. */
5152
public static final String PATH_REGIONS = "/availableRegions";
5253

54+
/** Get Available Regions. */
55+
public static final String PATH_REGIONS_SERVERLESS = "/regions/serverless";
56+
5357
/** Get Available Regions. */
5458
public static final String PATH_ACCESS_LISTS = "/access-lists";
5559

@@ -145,6 +149,19 @@ public Stream<DatabaseRegion> regions() {
145149
return unmarshallType(res.getBody(), TYPE_LIST_REGION).stream();
146150
}
147151

152+
/**
153+
* List serverless regions.
154+
*
155+
* @return
156+
* serverless region
157+
*/
158+
public Stream<DatabaseRegionServerless> regionsServerless() {
159+
// Invoke endpoint
160+
ApiResponseHttp res = http.GET(getApiDevopsEndpoint() + PATH_REGIONS_SERVERLESS, bearerAuthToken);
161+
// Marshall response
162+
return unmarshallType(res.getBody(), new TypeReference<List<DatabaseRegionServerless>>(){}).stream();
163+
}
164+
148165
/**
149166
* Map regions from plain list to Tier/Cloud/Region Structure.
150167
*

astra-shell/dependency-reduced-pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,39 @@
6161
</execution>
6262
</executions>
6363
</plugin>
64+
<plugin>
65+
<groupId>com.github.rvesse</groupId>
66+
<artifactId>airline-maven-plugin</artifactId>
67+
<version>${airline.version}</version>
68+
<executions>
69+
<execution>
70+
<phase>package</phase>
71+
<goals>
72+
<goal>validate</goal>
73+
<goal>generate</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
<configuration>
78+
<formats>
79+
<format>MAN</format>
80+
<format>CLI</format>
81+
<format>MARKDOWN</format>
82+
</formats>
83+
<sources>
84+
<source>
85+
<classes>
86+
<class>com.datastax.astra.shell.AstraCli</class>
87+
</classes>
88+
</source>
89+
<source>
90+
<classes>
91+
<class>com.datastax.astra.shell.AstraShell</class>
92+
</classes>
93+
</source>
94+
</sources>
95+
</configuration>
96+
</plugin>
6497
</plugins>
6598
</build>
6699
<dependencies>
@@ -102,7 +135,7 @@
102135
</dependency>
103136
</dependencies>
104137
<properties>
105-
<airline.version>2.7.2</airline.version>
138+
<airline.version>2.8.5</airline.version>
106139
<commons-cli.version>1.5.0</commons-cli.version>
107140
<maven-plugin-exec.version>3.0.0</maven-plugin-exec.version>
108141
<jansi.version>2.4.0</jansi.version>

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

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
import com.datastax.astra.shell.cmd.HelpCustomCommand;
55
import com.datastax.astra.shell.cmd.SetDefaultOrgCommand;
66
import com.datastax.astra.shell.cmd.ShowConfigCommand;
7+
import com.datastax.astra.shell.cmd.ShowRoleCommand;
8+
import com.datastax.astra.shell.cmd.ShowRolesCommand;
9+
import com.datastax.astra.shell.cmd.ShowUserCommand;
10+
import com.datastax.astra.shell.cmd.ShowUsersCommands;
11+
import com.datastax.astra.shell.cmd.db.CreateDatabaseCommand;
12+
import com.datastax.astra.shell.cmd.db.DeleteDatabaseCommand;
713
import com.datastax.astra.shell.cmd.db.ShowDatabasesCommand;
14+
import com.datastax.astra.shell.cmd.db.ShowDatabasesCommand.ShowDatabasesCommandBis;
815
import com.datastax.astra.shell.cmd.shell.ShellCommand;
916
import com.datastax.astra.shell.jansi.Out;
1017
import com.datastax.astra.shell.jansi.TextColor;
11-
import com.datastax.astra.shell.utils.ShellPrinter;
1218
import com.github.rvesse.airline.annotations.Cli;
1319
import com.github.rvesse.airline.annotations.Group;
1420
import com.github.rvesse.airline.parser.errors.ParseArgumentsUnexpectedException;
@@ -28,13 +34,30 @@
2834
ConfigCommand.class,
2935
SetDefaultOrgCommand.class
3036
},
31-
3237
groups = {
33-
@Group(
34-
name = "show",
35-
description = "Display entity or group of entities",
36-
commands = { ShowConfigCommand.class, ShowDatabasesCommand.class, }
37-
)
38+
@Group(
39+
name = "show", description = "Display an entity or a group of entities",
40+
commands = {
41+
ShowDatabasesCommand.class, ShowDatabasesCommandBis.class,
42+
ShowRoleCommand.class, ShowRolesCommand.class,
43+
ShowUserCommand.class, ShowUsersCommands.class,
44+
ShowConfigCommand.class
45+
}
46+
),
47+
@Group(
48+
name = "create",
49+
description = "Create an entity",
50+
commands = {
51+
CreateDatabaseCommand.class
52+
}
53+
),
54+
@Group(
55+
name = "delete",
56+
description = "Delete an entity",
57+
commands = {
58+
DeleteDatabaseCommand.class
59+
}
60+
)
3861
})
3962
public class AstraCli {
4063

@@ -50,9 +73,6 @@ public static void main(String[] args) {
5073

5174
try {
5275

53-
// Show Banner
54-
ShellPrinter.banner();
55-
5676
// Command Line Interface
5777
new com.github.rvesse.airline.Cli<Runnable>(AstraCli.class)
5878
.parse(args) // Find the processor for the command

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import com.datastax.astra.shell.cmd.ExitCommand;
44
import com.datastax.astra.shell.cmd.HelpCustomCommand;
55
import com.datastax.astra.shell.cmd.ShowConfigCommand;
6+
import com.datastax.astra.shell.cmd.ShowRoleCommand;
7+
import com.datastax.astra.shell.cmd.ShowRolesCommand;
8+
import com.datastax.astra.shell.cmd.ShowUserCommand;
9+
import com.datastax.astra.shell.cmd.ShowUsersCommands;
610
import com.datastax.astra.shell.cmd.db.ShowDatabasesCommand;
11+
import com.datastax.astra.shell.cmd.db.ShowDatabasesCommand.ShowDatabasesCommandBis;
712
import com.datastax.astra.shell.cmd.shell.ConnectCommand;
813
import com.datastax.astra.shell.cmd.shell.EmptyCommand;
914
import com.datastax.astra.shell.jansi.Out;
@@ -32,7 +37,11 @@
3237
@Group(
3338
name = "show",
3439
description = "Listing details of an entity or entity list",
35-
commands = { ShowConfigCommand.class, ShowDatabasesCommand.class }
40+
commands = {
41+
ShowDatabasesCommand.class, ShowDatabasesCommandBis.class,
42+
ShowRoleCommand.class, ShowRolesCommand.class,
43+
ShowUserCommand.class, ShowUsersCommands.class,
44+
ShowConfigCommand.class }
3645
)
3746
})
3847
public class AstraShell {

0 commit comments

Comments
 (0)