Exploring Stargate APIs from the command line - REST
In this section you will use our httpie configuration to take a look at the Stargate REST API.
- REST - Create Rows
- REST - Read Rows
- REST - Update Rows
- REST - Delete Rows
Did your token expire? Reset it with this command.
/workspace/httpie-katapod/token.sh
Great! The table is created. But it's kind of dull with no data. Go ahead and add a couple different rows with that data.
echo -n '
{
"firstname": "Mookie",
"lastname": "Betts",
"favorite color": "blue"
}' | http POST localhost:8082/v2/keyspaces/library/users
echo -n '
{
"firstname": "Janesha",
"lastname": "Doesha",
"favorite color": "grey"
}' | http POST localhost:8082/v2/keyspaces/library/users
Check to make sure they're really in there:
http localhost:8082/v2/keyspaces/library/users where=='{"firstname":{"$in":["Mookie","Janesha"]}}' -vvv
http PUT localhost:8082/v2/keyspaces/library/users/Janesha/Doesha "favorite color"=Fuchsia
Check our work:
http localhost:8082/v2/keyspaces/library/users where=='{"firstname":{"$in":["Mookie","Janesha"]}}' -vvv
Janesha has moved away. Let's remove them from the database.
http DELETE localhost:8082/v2/keyspaces/library/users/Janesha/Doesha
So wait, are they gone?
http localhost:8082/v2/keyspaces/library/users/Janesha/Doesha
We don't need our table anymore, let's delete it.
http DELETE localhost:8082/v2/schemas/keyspaces/library/tables/users
Double checking - what tables are in my keyspace?
http localhost:8082/v2/schemas/keyspaces/library/tables