Skip to content

Commit cd48d6a

Browse files
committed
OK
1 parent 9785572 commit cd48d6a

11 files changed

+189
-47
lines changed

README.MD

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
77
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
88
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=sqale_rating)](https://sonarcloud.io/summary/overall?id=clun_astra-cli)
9-
109
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=vulnerabilities)](https://sonarcloud.io/summary/overall?id=clun_astra-cli)
1110
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=bugs)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
11+
1212
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=coverage)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
13+
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
14+
![downloads](https://img.shields.io/github/downloads/datastax/astra-cli/total)
1315

1416
Astra CLI provides a command line interface in a terminal to operate Datastax Astra. The goal is to offer access to any feature without accessing the user interface. The component is still under development (version `0.1.alpha5`), it will keep moving before the release GA.
1517

@@ -101,8 +103,3 @@ git push
101103
```
102104
mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform
103105
```
104-
105-
![downloads](https://img.shields.io/github/downloads/datastax/astra-cli/total)
106-
107-
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=clun_astra-cli&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=clun_astra-cli)
108-

src/main/java/com/dtsx/astra/cli/AstraCli.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
import com.dtsx.astra.cli.iam.exception.UserNotFoundException;
4646
import com.dtsx.astra.cli.org.*;
4747
import com.dtsx.astra.cli.streaming.*;
48+
import com.dtsx.astra.cli.streaming.cdc.StreamingCreateCdcCmd;
49+
import com.dtsx.astra.cli.streaming.cdc.StreamingDeleteCdcCmd;
50+
import com.dtsx.astra.cli.streaming.cdc.StreamingGetCdcCmd;
4851
import com.dtsx.astra.cli.streaming.exception.TenantAlreadyExistException;
4952
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
5053
import com.dtsx.astra.cli.streaming.pulsarshell.PulsarShellCmd;
@@ -123,7 +126,9 @@
123126
StreamingPulsarTokenCmd.class, StreamingCreateDotEnvCmd.class,
124127
StreamingListRegionsCmd.class,
125128
// Pulsar Shell
126-
PulsarShellCmd.class
129+
PulsarShellCmd.class,
130+
// Create CDC
131+
StreamingCreateCdcCmd.class, StreamingDeleteCdcCmd.class, StreamingGetCdcCmd.class
127132
}),
128133

129134
@Group(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.dtsx.astra.cli.streaming;
2+
3+
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
4+
import com.github.rvesse.airline.annotations.Arguments;
5+
import com.github.rvesse.airline.annotations.restrictions.Required;
6+
7+
/**
8+
* Superclass when working with tenant.
9+
*/
10+
public abstract class AbstractStreamingCmd extends AbstractConnectedCmd {
11+
12+
/** name of the DB. */
13+
@Required
14+
@Arguments(title = "TENANT", description = "Tenant identifier")
15+
protected String tenant;
16+
17+
}

src/main/java/com/dtsx/astra/cli/streaming/StreamingDeleteCmd.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@
3232
* @author Cedrick LUNVEN (@clunven)
3333
*/
3434
@Command(name = "delete", description = "Delete an existing tenant")
35-
public class StreamingDeleteCmd extends AbstractConnectedCmd {
36-
37-
/** name of the DB. */
38-
@Required
39-
@Arguments(title = "TENANT", description = "Tenant name ")
40-
public String tenant;
35+
public class StreamingDeleteCmd extends AbstractStreamingCmd {
4136

4237
/** {@inheritDoc} */
4338
public void execute()

src/main/java/com/dtsx/astra/cli/streaming/StreamingExistCmd.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@
3131
* @author Cedrick LUNVEN (@clunven)
3232
*/
3333
@Command(name = OperationsStreaming.CMD_EXIST, description = "Show existence of a tenant")
34-
public class StreamingExistCmd extends AbstractConnectedCmd {
35-
36-
/** name of the DB. */
37-
@Required
38-
@Arguments(title = "TENANT", description = "Tenant name ")
39-
public String tenant;
34+
public class StreamingExistCmd extends AbstractStreamingCmd {
4035

4136
/** {@inheritDoc} */
4237
public void execute() {

src/main/java/com/dtsx/astra/cli/streaming/StreamingGetCmd.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
* #L%
2121
*/
2222

23-
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
2423
import com.dtsx.astra.cli.core.exception.InvalidArgumentException;
2524
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
26-
import com.github.rvesse.airline.annotations.Arguments;
2725
import com.github.rvesse.airline.annotations.Command;
2826
import com.github.rvesse.airline.annotations.Option;
29-
import com.github.rvesse.airline.annotations.restrictions.Required;
3027

3128
import java.util.Arrays;
3229

@@ -36,7 +33,7 @@
3633
* @author Cedrick LUNVEN (@clunven)
3734
*/
3835
@Command(name = "get", description = "Show details of a tenant")
39-
public class StreamingGetCmd extends AbstractConnectedCmd {
36+
public class StreamingGetCmd extends AbstractStreamingCmd {
4037

4138
/** Enum for db get. */
4239
public enum StreamingGetKeys {
@@ -83,12 +80,7 @@ public static StreamingGetKeys fromKey(String key) {
8380
return StreamingGetKeys.valueOf(key.toUpperCase());
8481
}
8582
}
86-
87-
/** name of the DB. */
88-
@Required
89-
@Arguments(title = "TENANT", description = "Tenant name ")
90-
public String tenant;
91-
83+
9284
/** Authentication token used if not provided in config. */
9385
@Option(name = { "-k", "--key" }, title = "Key", description = ""
9486
+ "Show value for a property among: "

src/main/java/com/dtsx/astra/cli/streaming/StreamingPulsarTokenCmd.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,17 @@
2020
* #L%
2121
*/
2222

23-
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
2423
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
25-
import com.github.rvesse.airline.annotations.Arguments;
2624
import com.github.rvesse.airline.annotations.Command;
27-
import com.github.rvesse.airline.annotations.restrictions.Required;
2825

2926
/**
3027
* Display information relative to a tenant.
3128
*
3229
* @author Cedrick LUNVEN (@clunven)
3330
*/
3431
@Command(name = OperationsStreaming.CMD_GET_TOKEN, description = "Show status of a tenant")
35-
public class StreamingPulsarTokenCmd extends AbstractConnectedCmd {
32+
public class StreamingPulsarTokenCmd extends AbstractStreamingCmd {
3633

37-
/** name of the DB. */
38-
@Required
39-
@Arguments(title = "TENANT", description = "Tenant name ")
40-
public String tenant;
41-
4234
/** {@inheritDoc} */
4335
public void execute()
4436
throws TenantNotFoundException {

src/main/java/com/dtsx/astra/cli/streaming/StreamingStatusCmd.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,16 @@
2020
* #L%
2121
*/
2222

23-
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
2423
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
25-
import com.github.rvesse.airline.annotations.Arguments;
2624
import com.github.rvesse.airline.annotations.Command;
27-
import com.github.rvesse.airline.annotations.restrictions.Required;
2825

2926
/**
3027
* Display information relative to a tenant.
3128
*
3229
* @author Cedrick LUNVEN (@clunven)
3330
*/
3431
@Command(name = OperationsStreaming.CMD_STATUS, description = "Show status of a tenant")
35-
public class StreamingStatusCmd extends AbstractConnectedCmd {
36-
37-
/** name of the DB. */
38-
@Required
39-
@Arguments(title = "TENANT", description = "Tenant name ")
40-
public String tenant;
32+
public class StreamingStatusCmd extends AbstractStreamingCmd {
4133

4234
/** {@inheritDoc} */
4335
public void execute()
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.dtsx.astra.cli.streaming.cdc;
2+
3+
/*-
4+
* #%L
5+
* Astra Cli
6+
* %%
7+
* Copyright (C) 2022 DataStax
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
24+
import com.dtsx.astra.cli.core.exception.InvalidArgumentException;
25+
import com.dtsx.astra.cli.streaming.AbstractStreamingCmd;
26+
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
27+
import com.github.rvesse.airline.annotations.Arguments;
28+
import com.github.rvesse.airline.annotations.Command;
29+
import com.github.rvesse.airline.annotations.Option;
30+
import com.github.rvesse.airline.annotations.restrictions.Required;
31+
32+
import java.util.Arrays;
33+
34+
/**
35+
* Display information relative to a db.
36+
*
37+
* @author Cedrick LUNVEN (@clunven)
38+
*/
39+
@Command(name = "create-cdc", description = "Create a CDC from a DB to Pulsar")
40+
public class StreamingCreateCdcCmd extends AbstractStreamingCmd {
41+
42+
/** Options. */
43+
@Option(name = {"-db", "--database" }, title = "DATABSE", arity = 1,
44+
description = "Database name or identifier")
45+
protected String db;
46+
47+
/** Options. */
48+
@Option(name = {"-k", "--keyspace" }, title = "KEYSPACE", arity = 1,
49+
description = "Authenticate to the given keyspace.")
50+
protected String keyspace;
51+
52+
/** Options. */
53+
@Option(name = {"-t", "--table" }, title = "TABLE", arity = 1,
54+
description = "Table name")
55+
protected String table;
56+
57+
@Option(name = {"-p", "--partition" }, title = "topicPartition",
58+
description = "Partition in topic")
59+
protected int topicPartition = 3;
60+
61+
/** {@inheritDoc} */
62+
public void execute()
63+
throws TenantNotFoundException {
64+
65+
}
66+
67+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.dtsx.astra.cli.streaming.cdc;
2+
3+
/*-
4+
* #%L
5+
* Astra Cli
6+
* %%
7+
* Copyright (C) 2022 DataStax
8+
* %%
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* #L%
21+
*/
22+
23+
import com.dtsx.astra.cli.core.AbstractConnectedCmd;
24+
import com.dtsx.astra.cli.streaming.AbstractStreamingCmd;
25+
import com.dtsx.astra.cli.streaming.exception.TenantNotFoundException;
26+
import com.github.rvesse.airline.annotations.Arguments;
27+
import com.github.rvesse.airline.annotations.Command;
28+
import com.github.rvesse.airline.annotations.Option;
29+
import com.github.rvesse.airline.annotations.restrictions.Required;
30+
31+
/**
32+
* Display information relative to a db.
33+
*
34+
* @author Cedrick LUNVEN (@clunven)
35+
*/
36+
@Command(name = "delete-cdc", description = "Delete a CDC from a DB to Pulsar if exist")
37+
public class StreamingDeleteCdcCmd extends AbstractStreamingCmd {
38+
39+
/** {@inheritDoc} */
40+
public void execute()
41+
throws TenantNotFoundException {
42+
43+
}
44+
45+
}

0 commit comments

Comments
 (0)