Skip to content
Go wrapper for Databox Push API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.md
databox.go
databox_test.go

README.md

Databox bindings for Go

Go wrapper for Databox - Mobile Executive Dashboard.

Build Status ReportCard

Installation

go install github.com/databox/databox-go
go get github.com/databox/databox-go # or this. :)

Usage

package main

import (
	databox "github.com/databox/databox-go"
	"fmt"
	"time"
)

func main() {
  client := databox.NewClient("<push token>")

	if _, err := client.Push(&databox.KPI{
		Key:	"temp.ny",
		Value: 	52.0,
		Date: 	"2015-01-01 09:00:00",
	}); err != nil {
		fmt.Println("Inserted.")
	}

  if data, _ := client.LastPushes(1) ; data != nil {
		for _, push := range data {
			printPush(push)
		}
  }

	// Additional attributes
  var attributes = make(map[string]interface{})
  attributes["test.number"] = 10
  attributes["test.string"] = "Oto Brglez"

	if _, err := client.Push(&databox.KPI{
		Key: "testing.this",
		Value: 10.0,
		Date: time.Now().Format(time.RFC3339),
		Attributes: attributes,
	}); err != nil {
		fmt.Println("Inserted.")
	}

  // Retriving last push
	if data, _ := client.LastPushes(1) ; data != nil {
		for _, push := range data {
			printPush(push)
		}
  }
}

func printPush(push databox.LastPush) {
	fmt.Println("Request")
	fmt.Println(" date: " + push.Request.Date)
	fmt.Print(" body: ")
	fmt.Println(push.Request.Body)
	fmt.Print(" errors: ")
	fmt.Println(push.Request.Errors)
	fmt.Println("")

	fmt.Println("Response")
	fmt.Println(" date: " + push.Response.Date)
	fmt.Print(" body: ")
	fmt.Println(push.Response.Body)
	fmt.Println("")

	fmt.Println("Metrics")
	for _, value := range push.Metrics {
		fmt.Println(" " + value)
	}
	fmt.Println("")
}

Development

# develop
docker run -it --rm -v "$PWD":/usr/local/go/src/databox golang:1.10 bash

# test
docker run -it --rm -v "$PWD":/usr/local/go/src/databox golang:1.10 make

Authors

-Oto Brglez -Vlada Petrovic

You can’t perform that action at this time.