Skip to content

Staash APIs

shyamalan edited this page Nov 5, 2014 · 18 revisions

Welcome to the staash wiki!

Staash is a middle tier service layer that provides restful interface to cassandra and can be extended to provide the same for other storage systems. This provides us the ability to automate a lot of user defined operations and build a facade on top of sql/nosql/storage systems that makes it easier for the user to interact with data without worrying about underlying datastores and the diverse technologies that they come with. It also allows us to identify patterns of operations that can be automated on the server and be made available out of the box. We have used curl commands in the samples below but the idea is to use any language like python, java-script etc to access a data store.

  1. Create a Storage (the Storage need to already exists, we are only creating the mapping here) :

    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"s1","type":"cassandra","cluster":"cluster_name","cl_read":"local_quorum","cl_write":"local_quorum","strategy":"network","rf":"region:3"}' "http://host:port/staash/v1/admin/storage

  • rf is defined as value of type ":<#replicas,..."
  • strategy network represent NetworkTopologyStrategy in cassandra
  • type defines the type of storage (we currently only support cassandra and mysql)
  1. Create a Database (The database is created which could have multiple tables spanning different storages) :

curl -H "Accept: application/json" -H "Content-type: application/json" -X post -d '{"name":"d1","optionalparams":"optional values"}' "http://host:port/staash/v1/admin/db"

  1. Create a Table (creates a table which is equivalent to creating a keyspace and a column family if it does not exist, fails otherwise) :
    curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"t1","columns":"username,friends,wall,status","primarykey":"username","storage":"s1", "db":"d1","optional params":"optional values"}' "http://host:port/staash/v1/admin/d1"

  2. Write a Row :

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"columns":"username,friends,wall,status","values":"'u1','f1','w1','s1'"}' "http://host:port/staash/v1/data/d1/t1"

  1. Read a Row

http://:/staash/v1/data/t1 -http://host:<port/staash/v1/data/t1/username/u1

  1. Create Time Series Curl with payload:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"time1",”periodicity":”60000"}' "http://:/staash/v1/admin/timeseries/d1"

  1. Create a storage for RDBMS Curl payload:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"mysqlremote","type":"mysql","jdbcurl":"jdbc:mysql://host:port/","host":"hostname","user":"username","password":"pass"}' "http://host:port/staash/v1/admin/storage"

  1. Create a Table Curl with Payload:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"t1join","columns":"username,firstname,lastname,fullname,paid,status,email,address","primarykey":"username","storage":"mysqlremote"}' "http://host:port/staash/v1/admin/d1"

  1. Insert a Row Curl with Payload:

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"columns":"username,firstname,lastname,fullname,paid,status,email,address","values":"'u1','federer','roger','roger federer','y','[email protected]','one swiss way,switzerland'"}' "http://host:port/staash/v1/data/d1/t1join"

  1. Read a Row:
  1. Do a natural join between the two tables in two different storages:
  1. Get all databases
  1. Get all tables in a database
  1. List all storages
  1. List all time series in a database

Staash Metadata Artifacts

The metadata layer supports following high level concepts out of the box:

  • Storage - The configuration for storing your data, includes stuff like cluster name, type, any defaults that you want to be followed. This defines the composition of physical hardware and technology types along with any type specific defaults.
  • Database - A container of tables, can extend across multiple storages.
  • Table - A container for your data
Clone this wiki locally