Skip to content

Latest commit

 

History

History
110 lines (88 loc) · 2.92 KB

step2-cassandra.md

File metadata and controls

110 lines (88 loc) · 2.92 KB
Exploring Stargate with HTTPie ℹ️ For technical support, please contact us via email or LinkedIn.
⬅️ Back Step 2 of 3 Next ➡️ REST Rows
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 - List Keyspaces
  • REST - Create a Table
  • REST - Retrieve Tables

Did your token expire? Reset it with this command.

/workspace/httpie-katapod/token.sh

1. Create a table

The first thing that needs to happen is to create a table. HTTPie will handle the authentication and create the right server based on your .astrarc file, but you'll need to make sure and use that "library" keyspace.

Here are the steps:

A. Check for your keyspace

http http://localhost:8082/v2/schemas/keyspaces

Do you see 'library' in there? Great, we're ready to move on.

You could also check for a specific keyspace:

http http://localhost:8082/v2/schemas/keyspaces/library

B. Create the tables

echo -n '{
	"name": "users",
	"columnDefinitions":
	  [
        {
	      "name": "firstname",
	      "typeDefinition": "text"
	    },
        {
	      "name": "lastname",
	      "typeDefinition": "text"
	    },
        {
	      "name": "favorite color",
	      "typeDefinition": "text"
	    }
	  ],
	"primaryKey":
	  {
	    "partitionKey": ["firstname"],
	    "clusteringKey": ["lastname"]
	  },
	"tableOptions":
	  {
	    "defaultTimeToLive": 0,
	    "clusteringExpression":
	      [{ "column": "lastname", "order": "ASC" }]
	  }
}' | http POST localhost:8082/v2/schemas/keyspaces/library/tables

Just to be sure, go ahead and ask for a listing of the tables in the library keyspace:

http localhost:8082/v2/schemas/keyspaces/library/tables

or specify the table you want:

http localhost:8082/v2/schemas/keyspaces/library/tables/users
⬅️ Back - Credentials Next ➡️ REST Rows