Skip to content

Commit 7146b6e

Browse files
committed
update installation script
1 parent b3efda6 commit 7146b6e

File tree

5 files changed

+40
-36
lines changed

5 files changed

+40
-36
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.datastax.astra.sdk.stargate;
2+
3+
public class ApiGraphQLAstraTest {
4+
5+
}

astra-shell/dist/astra-install.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if [ -d "$ASTRA_DIR" ]; then
8282
echo " ${ASTRA_CLI_DIR}"
8383
echo ""
8484
echo " Please delete this folder if you need to upgrade."
85+
echo " rm -Rf ${ASTRA_CLI_DIR}"
8586
echo "======================================================================================================"
8687
echo ""
8788
exit 0
@@ -131,7 +132,6 @@ mkdir -p "$astra_tmp_folder"
131132
echo "$(tput setaf 2)[OK]$(tput setaf 7) - Created $astra_tmp_folder"
132133
mkdir -p "$ASTRA_CLI_DIR"
133134
echo "$(tput setaf 2)[OK]$(tput setaf 7) - Created $ASTRA_CLI_DIR"
134-
135135
echo ""
136136
echo "Downloading archive:"
137137
download_url="https://github.com/datastaxdevs/datastaxdevs.github.io/raw/master/cli/${ASTRA_CLI_VERSION}.zip"
@@ -193,18 +193,10 @@ touch "$astra_zshrc"
193193
if [[ -z $(grep 'astra-init.sh' "$astra_zshrc") ]]; then
194194
echo -e "\n$astra_init_snippet" >> "$astra_zshrc"
195195
echo "$(tput setaf 2)[OK]$(tput setaf 7) - astra added to ${astra_zshrc}"
196-
echo "Updated existing ${astra_zshrc}"
197196
fi
198197

199-
200-
echo "$(tput setaf 2)[OK]$(tput setaf 7) - ALL DONE"
201-
202-
echo ""
203-
echo "Please open a new terminal, or run the following in the existing one:"
204-
echo ""
205-
echo " source \"${ASTRA_CLI_DIR}/astra-init.sh\""
198+
echo "$(tput setaf 2)[OK]$(tput setaf 7) - Installation Successful"
206199
echo ""
207-
echo "Then issue the following command:"
200+
echo "Open $(tput setaf 2)A NEW TERMINAL$(tput setaf 7) and run: $(tput setaf 3)astra setup$(tput setaf 7)"
208201
echo ""
209-
echo " astra setup"
210-
echo ""
202+
echo "You can close this window."

stargate-sdk/src/main/java/com/datastax/stargate/sdk/gql/CqlKeyspaceClient.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ public String query(String input) {
5050
return res.getBody();
5151
}
5252

53-
/**
54-
* List tables.
55-
*
56-
* @return
57-
* return list of table
58-
*/
59-
public String listTables() {
60-
return query(GraphQLQueryBuilder.queryListTables(this.keyspace));
61-
}
62-
6353
/**
6454
* Mapping from root URL to rest endpoint listing keyspaces definitions.
6555
*/

stargate-sdk/src/main/java/com/datastax/stargate/sdk/gql/CqlSchemaClient.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import static com.datastax.stargate.sdk.utils.JsonUtils.unmarshallType;
44

5+
import java.util.Optional;
56
import java.util.function.Function;
67
import java.util.stream.Stream;
78

9+
import com.datastax.stargate.graphql.client.KeyspaceGraphQLQuery;
10+
import com.datastax.stargate.graphql.client.KeyspaceProjectionRoot;
811
import com.datastax.stargate.graphql.client.KeyspacesGraphQLQuery;
912
import com.datastax.stargate.graphql.client.KeyspacesProjectionRoot;
1013
import com.datastax.stargate.graphql.types.Keyspace;
@@ -69,15 +72,39 @@ public Stream<Keyspace> keyspaces() {
6972
* list of keyspaces.
7073
*/
7174
public Stream<Keyspace> keyspaces(KeyspacesProjectionRoot projection) {
72-
String res = query(new GraphQLQueryRequest(
75+
// Shape your request
76+
String graphQLRequest = new GraphQLQueryRequest(
7377
new KeyspacesGraphQLQuery.Builder().build(),
74-
projection).serialize());
75-
return unmarshallType(res, new TypeReference<ApiResponse<Keyspaces>>(){})
78+
projection).serialize();
79+
// Invoke endpoint
80+
ApiResponseHttp res = stargateHttpClient.POST_GRAPHQL(cqlSchemaResource, graphQLRequest);
81+
// Marshall output
82+
return unmarshallType(res.getBody(), new TypeReference<ApiResponse<Keyspaces>>(){})
7683
.getData()
7784
.getKeyspaces()
7885
.stream();
7986
}
8087

88+
/**
89+
* Using the keyspace(...) functions about cqlShema.
90+
*
91+
* @param keyspaceName
92+
* keyspace name
93+
* @param projection
94+
*
95+
* @return
96+
*/
97+
public Optional<Keyspace> keyspace(String keyspaceName, KeyspaceProjectionRoot projection) {
98+
String graphQLRequest = new GraphQLQueryRequest(
99+
new KeyspaceGraphQLQuery.Builder().name(keyspaceName).build(),
100+
projection).serialize();
101+
// Invoke endpoint
102+
ApiResponseHttp res = stargateHttpClient.POST_GRAPHQL(cqlSchemaResource, graphQLRequest);
103+
// Marshall output
104+
return Optional.ofNullable(unmarshallType(res.getBody(),
105+
new TypeReference<ApiResponse<Keyspace>>(){}).getData());
106+
}
107+
81108
/**
82109
* Mutation to create a keyspace.
83110
*

stargate-sdk/src/main/java/com/datastax/stargate/sdk/gql/GraphQLQueryBuilder.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,7 @@ public class GraphQLQueryBuilder {
1111
* Hide default constructor.
1212
*/
1313
private GraphQLQueryBuilder() {}
14-
15-
/**
16-
* List keyspaces.
17-
*
18-
* @return
19-
* a query.
20-
*/
21-
public static String queryListKeyspaces() {
22-
return "{ keyspaces { name } }";
23-
}
24-
14+
2515
/**
2616
* List tables in a keyspace.
2717
*

0 commit comments

Comments
 (0)