Skip to content

Commit da4e7d4

Browse files
authored
Merge branch 'main' into snyk-upgrade-f3d1bd263a3e232cc4fee57deff2667d
2 parents 7cf445c + b85c541 commit da4e7d4

File tree

7 files changed

+61
-20
lines changed

7 files changed

+61
-20
lines changed

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/AbstractApiClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ public ApiResponseHttp POST(String url, String body) {
101101
* url
102102
* @param body
103103
* body
104-
* @return
105-
* response
106104
*/
107105
public void PUT(String url, String body) {
108106
getHttpClient().PUT(url, getToken(), body);
@@ -113,8 +111,6 @@ public void PUT(String url, String body) {
113111
*
114112
* @param url
115113
* url
116-
* @return
117-
* response
118114
*/
119115
public void DELETE(String url) {
120116
getHttpClient().DELETE(url, getToken());
@@ -129,7 +125,6 @@ public void DELETE(String url) {
129125
* action taken
130126
* @param entityId
131127
* entity id
132-
133128
*/
134129
public void assertHttpCodeAccepted(ApiResponseHttp res, String action, String entityId) {
135130
String errorMsg = " Cannot " + action + " id=" + entityId + " code=" + res.getCode() + " msg=" + res.getBody();

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbDatacentersClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public Optional<Datacenter> findByRegionName(String regionName) {
8181
*
8282
* @param regionName
8383
* region name
84+
* @return
85+
* if region exist
8486
*/
8587
public boolean exist(String regionName) {
8688
return findByRegionName(regionName).isPresent();

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/db/DbKeyspacesClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public void create(String keyspace) {
4545
/**
4646
* Endpoint to access keyspace. (static).
4747
*
48+
* @param keyspaceName
49+
* name of keyspace
4850
* @return endpoint
4951
*/
5052
public String getEndpointKeyspace(String keyspaceName) {

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/RolesClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public Stream<Role> findAll() {
5858
/**
5959
* Retrieve role information from its id.
6060
*
61+
* @param roleId
62+
* role identifier
6163
* @return
6264
* role information
6365
*/
@@ -73,6 +75,8 @@ public Optional<Role> find(String roleId) {
7375
/**
7476
* Access the role if exist or exception.
7577
*
78+
* @param roleId
79+
* role identifier
7680
* @return
7781
* role
7882
*/
@@ -95,6 +99,8 @@ public Optional<Role> find(DefaultRoles role) {
9599
/**
96100
* Access the role if exist or exception.
97101
*
102+
* @param role
103+
* current role
98104
* @return
99105
* role
100106
*/
@@ -118,6 +124,8 @@ public Optional<Role> findByName(String roleName) {
118124
/**
119125
* Access the role if exist or exception.
120126
*
127+
* @param roleName
128+
* role name
121129
* @return
122130
* role
123131
*/
@@ -142,6 +150,8 @@ public CreateRoleResponse create(RoleDefinition cr) {
142150
/**
143151
* Check if a role is present
144152
*
153+
* @param roleId
154+
* role identifier
145155
* @return
146156
* if current role with id exist
147157
*/
@@ -151,6 +161,9 @@ public boolean exist(String roleId) {
151161

152162
/**
153163
* Delete a role from its id.
164+
*
165+
* @param roleId
166+
* role identifier
154167
*/
155168
public void delete(String roleId) {
156169
// Ensure role exist
@@ -162,6 +175,8 @@ public void delete(String roleId) {
162175
/**
163176
* Update an existing role.
164177
*
178+
* @param roleId
179+
* role identifier
165180
* @param cr
166181
* role definition
167182
*/

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/org/UsersClient.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public Stream<User> findAll() {
4444
/**
4545
* Retrieve user information from its id.
4646
*
47+
* @param userId
48+
* user identifier
4749
* @return
4850
* user information
4951
*/
@@ -72,6 +74,8 @@ public Optional<User> findByEmail(String email) {
7274
/**
7375
* Check if a role is present
7476
*
77+
* @param userId
78+
* user identifier
7579
* @return
7680
* iif the user exists
7781
*/
@@ -84,13 +88,18 @@ public boolean exist(String userId) {
8488
*
8589
* @param userEmail
8690
* user emails
91+
* @return
92+
* if the user exists
8793
*/
8894
public boolean existByEmail(String userEmail) {
8995
return findByEmail(userEmail).isPresent();
9096
}
9197

9298
/**
9399
* Delete a role from its id.
100+
*
101+
* @param userId
102+
* user identifier
94103
*/
95104
public void delete(String userId) {
96105
if (!exist(userId)) {
@@ -148,6 +157,8 @@ public void invite(String email, String... roles) {
148157
/**
149158
* Replace roles of users.
150159
*
160+
* @param userId
161+
* user identifier
151162
* @param roles
152163
* replace existing roles of a user
153164
*/
@@ -191,6 +202,8 @@ public static String getEndpointUsers() {
191202
/**
192203
* Endpoint to access dbs.
193204
*
205+
* @param userId
206+
* user identifier
194207
* @return
195208
* database endpoint
196209
*/

astra-sdk-devops/src/main/java/com/dtsx/astra/sdk/streaming/AstraStreamingClient.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public Stream<Tenant> findAll() {
4848
/**
4949
* Find a tenant from ids name.
5050
*
51+
* @param tenantName
52+
* name of the tenant
5153
* @return
5254
* tenant
5355
*/
@@ -60,6 +62,8 @@ public Optional<Tenant> find(String tenantName) {
6062
/**
6163
* Assess a tenant exist and retrieve information.
6264
*
65+
* @param tenantName
66+
* name of the tenant
6367
* @return
6468
* tenant reference
6569
*/
@@ -80,6 +84,9 @@ public void create(CreateTenant ct) {
8084

8185
/**
8286
* Deleting a tenant and cluster.
87+
*
88+
* @param tenantName
89+
* name of the tenant
8390
*/
8491
public void delete(String tenantName) {
8592
Tenant tenant = get(tenantName);
@@ -89,6 +96,8 @@ public void delete(String tenantName) {
8996
/**
9097
* Check if a role is present
9198
*
99+
* @param tenantName
100+
* name of the tenant
92101
* @return
93102
* if the tenant exist
94103
*/
@@ -181,6 +190,8 @@ public static String getApiDevopsEndpointTenants() {
181190
/**
182191
* Endpoint to access dbs.
183192
*
193+
* @param tenantId
194+
* identifier for tenant
184195
* @return
185196
* database endpoint
186197
*/
@@ -191,13 +202,15 @@ public static String getEndpointTenant(String tenantId) {
191202
/**
192203
* Endpoint to access cluster.
193204
*
205+
* @param tenantName
206+
* name of the tenant
194207
* @param clusterId
195208
* identifier for the cluster.
196209
*
197210
* @return
198211
* database endpoint
199212
*/
200-
public String getEndpointCluster(String tenantId, String clusterId) {
201-
return getEndpointTenant(tenantId) + "/clusters/" + clusterId;
213+
public String getEndpointCluster(String tenantName, String clusterId) {
214+
return getEndpointTenant(tenantName) + "/clusters/" + clusterId;
202215
}
203216
}

astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.datastax.astra.sdk.config.AstraClientConfig;
2020
import com.datastax.oss.driver.api.core.CqlSession;
21+
import com.dtsx.astra.sdk.AstraDevopsApiClient;
2122
import com.dtsx.astra.sdk.utils.ApiLocator;
2223
import io.stargate.sdk.StargateClient;
2324
import io.stargate.sdk.api.SimpleTokenProvider;
@@ -55,13 +56,13 @@ public class AstraClient implements Closeable {
5556
// -----------------------------------------------------
5657
// --------- Devops API Endpoints ---------------------
5758
// -----------------------------------------------------
58-
59+
5960
/** Hold a reference for the Api Devops. */
60-
private AstraDbClient apiDevopsDatabases;
61-
61+
private AstraDevopsApiClient apiDevops;
62+
6263
/** Hold a reference for the Api Devops. */
63-
private OrganizationsClient apiDevopsOrganizations;
64-
64+
private AstraDbClient apiDevopsDatabases;
65+
6566
/** Hold a reference for the Api Devops. */
6667
private AstraStreamingClient apiDevopsStreaming;
6768

@@ -118,9 +119,9 @@ public AstraClient(AstraClientConfig config) {
118119
// Devops APIS
119120
// ---------------------------------------------------
120121
if (Utils.hasLength(config.getToken())) {
121-
apiDevopsOrganizations = new OrganizationsClient(config.getToken());
122-
apiDevopsDatabases = new AstraDbClient(config.getToken());
123-
apiDevopsStreaming = new AstraStreamingClient(config.getToken());
122+
apiDevops = new AstraDevopsApiClient(config.getToken());
123+
apiDevopsDatabases = apiDevops.db();
124+
apiDevopsStreaming = apiDevops.streaming();
124125
LOGGER.info("+ API(s) Devops [" + AnsiUtils.green("ENABLED")+ "]");
125126
} else {
126127
LOGGER.info("+ API(s) Devops [" + AnsiUtils.red("DISABLED")+ "]");
@@ -166,7 +167,7 @@ public AstraClient(AstraClientConfig config) {
166167
// ---------------------------------------------------
167168

168169
if (config.isEnabledCrossRegionFailOver()) {
169-
Optional<Database> db = apiDevopsDatabases.dbClientById(config.getDatabaseId()).find();
170+
Optional<Database> db = apiDevopsDatabases.database(config.getDatabaseId()).find();
170171
if (!db.isPresent()) {
171172
throw new IllegalArgumentException("Cannot retrieve db with id " + config.getDatabaseId());
172173
}
@@ -267,7 +268,7 @@ private void downloadAndSetupSecureConnectBundle(AstraClientConfig config) {
267268
}
268269
// Download secure bundles (if needed)
269270
LOGGER.info("+ Downloading bundles in: [" + AnsiUtils.cyan("{}") + "]", config.getSecureConnectBundleFolder());
270-
apiDevopsDatabases.dbClientById(config.getDatabaseId())
271+
apiDevopsDatabases.database(config.getDatabaseId())
271272
.downloadAllSecureConnectBundles(config.getSecureConnectBundleFolder());
272273

273274
// Setup the current region
@@ -335,12 +336,12 @@ public StargateGrpcApiClient apiStargateGrpc() {
335336
*
336337
* @return ApiDevopsClient
337338
*/
338-
public OrganizationsClient apiDevopsOrganizations() {
339-
if (apiDevopsOrganizations == null) {
339+
public AstraDevopsApiClient apiDevops() {
340+
if (apiDevops == null) {
340341
throw new IllegalStateException("Api Devops is not available "
341342
+ "you need to provide a astra Token (AstraCS:...) at initialization.");
342343
}
343-
return apiDevopsOrganizations;
344+
return apiDevops;
344345
}
345346

346347
/**

0 commit comments

Comments
 (0)