Skip to content

Commit 5c7a24d

Browse files
committed
OK
1 parent 89ccc99 commit 5c7a24d

File tree

3 files changed

+117
-38
lines changed

3 files changed

+117
-38
lines changed

astra-shell/README.MD

Lines changed: 116 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ curl -Ls "https://dtsx.io/get-astra-cli" | bash
3535

3636
### 1.3 - Setup
3737

38-
#### ✅ Step 1.3.a. Execute `startup` command
38+
#### ✅ Step 1.3.a - Execute `startup` command
3939

4040
```
4141
astra setup
4242
```
4343

44-
#### ✅ Step 1.3.b. Provide a token of your choice when needed
44+
#### ✅ Step 1.3.b - Provide a token of your choice when needed
4545

4646
```
4747
Enter your token (AstraCS...) :
@@ -50,48 +50,84 @@ AstraCS:.......
5050

5151
![](https://github.com/datastax/astra-sdk-java/blob/main/docs/img/astra-shell-config.png?raw=true")
5252

53-
#### ✅ Step 1.3.b. Open a `new` shell to finalize install
53+
```
54+
[What's NEXT ?]
55+
You are all set. You can now:
56+
• Use any command, 'astra help' will get you the list
57+
• Try with 'astra db list'
58+
• Enter interactive mode using 'astra'
59+
60+
Happy Coding !
61+
```
62+
63+
#### ✅ Step 1.3.c - Open a `NEW` shell to finalize install
64+
65+
- Get the current version
5466

5567
```
5668
astra --version
69+
```
70+
71+
- Get some more informations
72+
73+
```
5774
astra help
5875
```
5976

77+
- Use you configuration (spoiler)
78+
79+
```
80+
astra user list
81+
```
82+
6083
## 2. Configuration Management
6184

62-
- **List Configurations**
85+
#### ✅ Step 2.1 - List Configuration
86+
87+
- In your configuration file you see all config and one is the default. This is the one used when no option provided.
6388

6489
```
6590
astra config list
6691
```
6792

68-
- **Create new configuration**
93+
#### ✅ Step 2.2 - Create new configuration
94+
95+
If you have multiple organizations it could be useful to switch from one to another.
6996

70-
If you have multiple organizations it could be useful to switch from one to another. To create another config, the latest created org will become the default.
97+
- Create another org called `dev`
7198

7299
```
73100
astra config create dev -t <token_of_org_2>
74101
```
75102

103+
- Look at the new list with `dev`
104+
76105
```
77106
astra config list
78107
```
79108

80-
When you issue any command the config is now loaded for you:
109+
- But nothing change your are still on default
81110

82111
```
83112
astra user list
84113
```
85114

86-
- **Change default configuration**:
115+
#### ✅ Step 2.3 - Change default configuration
87116

88117
You can change the default org at any time with the following command:
89118

119+
- Change the default
90120
```
91-
astra config default dev && astra config list
121+
astra config default dev
92122
```
93123

94-
- Test again, user list should be different
124+
- See your new list
125+
126+
```
127+
astra config list
128+
```
129+
130+
- Test again, user list should be different now
95131

96132
```
97133
astra user list
@@ -109,63 +145,85 @@ astra config default [email protected] && astra config list
109145
astra user list --config dev
110146
```
111147

112-
- **Delete configuration**
148+
#### ✅ Step 2.4 = Delete configuration
113149

114150
You can delete any organization. I see you.. if you delete the default one you are on your own and you would need to define a new one.
115151

152+
- Delete you config
116153
```
117154
astra config delete dev
155+
```
156+
157+
- See the new list
158+
159+
```
118160
astra config list
119161
```
120162

121163
## 3. Working with Databases
122164

123-
- **List Databases**:
165+
#### ✅ Step 3.1 List Databases
124166

125167
```
126168
astra db list
127169
```
128170

129-
- **Create a new database:**
171+
#### ✅ Step 3.2 Create a new database
130172

131173
If not provided the region will be the default free region and the keyspace will be the database name but you can change then with `-r` and `-k` respectivitely.
132174

175+
- Create the Database
176+
133177
```
134178
astra db create demo
135-
astra db list
136179
```
137180

138-
- **Get information on your database**
181+
- Check the status
139182

140-
Notice how you never provide any the technical ids.
183+
```
184+
astra db list
185+
```
186+
187+
#### ✅ Step 3.3 Get information on your database
141188

142189
```
143190
astra db get demo
144191
```
145192

146-
- **Change output format**
193+
> **Note:** You never provided any the technical ids.
194+
195+
196+
#### ✅ Step 3.4 Output Format
147197

148198
This CLI wil be used by CI/CD and script, sometimes the output must be parsed. There are 3 outputs: *human,json,csv"
149199

200+
- Show the list as a json
201+
150202
```
151203
astra db list -o json
152204
```
153205

206+
- Show the list as a csv
207+
154208
```
155209
astra db list -o csv
156210
```
157211

212+
#### ✅ Step 3.5 Error Code
213+
158214
The return type is also important to check the errors. O mean everything is OK
159215

216+
- Execute command with error
160217
```
161-
echo $?
218+
astra db get i_do_not_exist -v
162219
```
163220

221+
- Get the error code
164222
```
165-
astra db get i_do_not_exist && echo $?
223+
echo $?
166224
```
167225

168-
Error codes tables
226+
- Error codes table:
169227

170228
| Error | Code |
171229
|-------------------|-----------|
@@ -179,10 +237,14 @@ Error codes tables
179237
| INTERNAL_ERROR | 40 |
180238

181239

182-
- The cli implemented `If not Exist` for both keyspace and database (convenient for workshops and training)
240+
#### ✅ Step 3.6 - If not Exists
241+
242+
The cli implemented `If not Exist` for both keyspace and database (convenient for workshops and training)
243+
244+
245+
- Run the command with `--if-not-exist`
183246

184247
```
185-
astra help db create
186248
astra db create demo --if-not-exist
187249
```
188250

@@ -194,21 +256,27 @@ astra db create demo --if-not-exist -v
194256

195257
Make sure the database is now Active or you will get some expected errors.
196258

197-
- **Create a new keyspace**
259+
```
260+
astra db get demo | grep ACTIVE
261+
```
198262

263+
#### ✅ Step 3.7 - Create Keyspace
199264
```
200265
astra db create-keyspace demo -k ks2
201266
```
202267

203-
Need helps ?
268+
- Keyspace is created
269+
204270
```
205-
astra help db create-keyspace
271+
astra db get demo
206272
```
207273

208-
- Now let's blow your mind 🥁
274+
#### ✅ Step 3.8 - Blow your mind 🥁
275+
276+
The first execution is expected to be slow we are downloading cqlsh if not present on your machine. This is why we put the `-v`.
209277

210278
```
211-
astra db cqlsh demo
279+
astra db cqlsh demo -v
212280
```
213281

214282
- Quit the shell
@@ -217,16 +285,18 @@ astra db cqlsh demo
217285
quit;
218286
```
219287

220-
- Execute CQL (or CQL file)
288+
- Execute a CQL statement (or a CQL file with `-f`)
221289

222290
```
223291
astra db cqlsh demo -e "describe keyspaces;"
224292
```
225293

226-
### D. Interactive mode
294+
#### ✅ Step 3.9 - Interactive Shell
227295

228296
Commands we used so far are stateless, no connection is maintained after the execution. What if you need more an interactive shell than a cli ?
229297

298+
- Start the shell by do not providing any command
299+
230300
```
231301
astra
232302
```
@@ -243,12 +313,14 @@ db list
243313
db get demo
244314
```
245315

246-
Now what if we want some commands on this particular db ?
316+
- Now what if we want some commands on this particular db ?
247317

248318
```
249319
db use demo
250320
```
251321

322+
- Get info of a
323+
252324
```
253325
info
254326
```
@@ -267,42 +339,49 @@ create keyspace kso
267339
cqlsh -k kso
268340
```
269341

270-
Now quit:
342+
- No Quit:
271343

272344
```
273345
quit;
274346
```
275347

276348
## 4. Working with Users
277349

278-
- List your users
350+
#### ✅ Step 4.1 - List your users
279351

280352
```
281353
astra user list
282354
```
283355

284-
- Invite your best friend (me). The role will be DataStax Administrator by default
356+
#### ✅ Step 4.2 - Invite your best friend (me).
357+
358+
- The role will be `DataStax Administrator` by default
285359

286360
```
287361
astra user invite [email protected]
288-
astra db list
289362
```
290363

291-
- Delete a user
364+
- And here I am
365+
366+
```
367+
astra user list
368+
```
369+
370+
#### ✅ Step 4.3 - Delete a user
292371

293372
```
294373
astra user delete [email protected]
295374
```
296375

297376
## 5. Working with Roles
298377

299-
- List your users
378+
#### ✅ Step 5.1 - List your roles
300379

301380
```
302381
astra role list
303382
```
304383

305-
- Delete a user
384+
#### ✅ Step 5.2 - Get a role
306385

307386
```
308387
astra role get "Organization Administrator"

astra-shell/dist/astra-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ASTRA_CLI_DIR="$HOME/.astra/cli"
3434

3535
# Local variables
3636
astra_tmp_folder="$HOME/.astra/tmp"
37-
astra_scb_folder="$HOME/.astra/cli/scb"
37+
astra_scb_folder="$HOME/.astra/scb"
3838
astra_zip_file="${astra_tmp_folder}/astra-cli-${ASTRA_CLI_VERSION}.zip"
3939
astra_zip_base_folder="${astra_tmp_folder}/astra-cli-${ASTRA_CLI_VERSION}"
4040

docs/img/astra-shell-config.png

-6.64 KB
Loading

0 commit comments

Comments
 (0)