Categorygithub.com/bureau14/qdb-api-rest
module
3.14.1+incompatible
Repository: https://github.com/bureau14/qdb-api-rest.git
Documentation: pkg.go.dev

# README

qdb-api-rest

I. Try it with docker

Preliminary

Download quasardb tools

Install qdb-server on your own machine to make qdb_user_add and qdb_cluster_keygen available.

wget https://download.quasardb.net/quasardb/nightly/server/qdb-3.0.0master-linux-64bit-server.tar.gz
tar qdb-3.0.0master-linux-64bit-server.tar.gz --no-same-owner -C /usr/local/
rm qdb-3.0.0master-linux-64bit-server.tar.gz
Generate a user key
/usr/local/bin/qdb_user_add -u tintin -s tintin.private -p users.cfg
Generate a cluster key
/usr/local/bin/qdb_cluster_keygen -p cluster.public -s cluster.private

Setup quasardb

docker pull bureau14/qdb:nightly

export QDB_QDDB_DIR=`pwd`/qdb-var-qdbd
mkdir $QDB_QDDB_DIR
cp users.cfg $QDB_QDDB_DIR/.
cp cluster.private $QDB_QDDB_DIR/.

Build

docker build -t qdb-api-rest-server .

Setup

export QDB_REST_DIR=`pwd`/qdb-var-rest
mkdir $QDB_REST_DIR
cp cluster.public $QDB_REST_DIR/.
cp rest-api.cfg $QDB_REST_DIR/.

Run

docker run -d -v $QDB_QDDB_DIR:/var/lib/qdb --name qdb-server bureau14/qdb:nightly --cluster-private-file /var/lib/qdb/cluster.private --user-list /var/lib/qdb/users.cfg

docker run -it --link qdb-server:qdb -v $QDB_REST_DIR:/var/lib/qdb -p 40080:40080 qdb-api-rest-server qdb://qdb:2836

II. Build locally

go get -u github.com/go-swagger/go-swagger/cmd/swagger
$GOPATH/bin/swagger generate server -f ./swagger.json -A qdb-api-rest -P models.Principal --exclude-main
cp configure_qdb_rest.go restapi/configure_qdb_rest.go
go install ./...

IV. Example

Login

curl -k -H 'Origin: http://0.0.0.0:3449'  -H "Content-Type: application/json" -X POST --data-binary @tintin.private http://127.0.0.1:40080/api/login

Get cluster information

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -i https://localhost:40080/api/cluster

Get node information

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -i http://127.0.0.1:40080/api/cluster/nodes/127.0.0.1:2836

Run a query

curl -k -H "Authorization: Bearer ${TOKEN}" -H 'Origin: http://0.0.0.0:3449' -sb -X POST -H "Content-Type: application/json" -d '"select count(*) from timeseries in range (2017,+1y)"' http://127.0.0.1:40080/api/query

V. Config File

The config file need to specify the following values:

  1. allowed_origins - description: "allowed origins"
  2. cluster_uri - description: "the uri of the cluster"
  3. cluster_public_key_file - description: "cluster public key path"
  4. tls_certificate - description: "certificate path"
  5. tls_key - description: "certificate key path"
  6. host - description: "host of the rest api"
  7. port - description: "port of the rest api"
  8. assets - description: "served assets path"
  9. max_in_buffer_size - description: "maximum input buffer incomming from the server"

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package restapi QuasarDB API Find out more at https://doc.quasardb.net Schemes: http https Host: localhost BasePath: /api Version: 3.14.1 Consumes: - application/json - application/x-protobuf Produces: - text/csv - application/json - application/x-protobuf swagger:meta.