Go/Golang client library for Geckoboard API (https://developer.geckoboard.com/api-reference/).
go get github.com/influx6/geckoclient
To run tests you need to provided a test client API Authentication key as an environment variable GECKOBOARD_TEST_API_KEY
.
GECKOBOARD_TEST_API_KEY=222efc82e7933138077b1c2554439e15 go test -v
New Client verifies API Key to ensure user has valid API auth.
client, err := geckoclient.New("222efc82e7933138077b1c2554439e15")
Create new dataset.
client.Create(context.Background(), "sales.gross", geckoclient.NewDataset{
UniqueBy: []string{"date"},
Fields: map[string]geckoclient.DataType{
"name": geckoclient.StringType{
Name: "transaction_target",
},
"amount": geckoclient.NumberType{
Name: "transaction_amount",
},
"date": geckoclient.DateType{
Name: "transaction_date",
},
},
})
UniqueBy
is an optional array of one or more field names whose values will be unique across all your records.
Available field types:
DateType
DateTimeType
NumberType
PercentageType
StringType
MoneyType
Delete a dataset and all data therein.
client.Delete(context.Background(), "sales.gross")
Replace all data in the dataset.
client.ReplaceData(context.Background(), "sales.gross", geckoclient.Dataset{
Data: []map[string]interface{}{
{
"amount": 300,
"name": "Waxon Butter",
"date": now.Format(isoTime),
},
{
"amount": 1300,
"name": "Shred Lack",
"date": now.Add(time.Hour * 30).Format(isoTime),
},
{
"amount": 500,
"name": "Creg Washer",
"date": now.Add(time.Hour * 10).Format(isoTime),
},
},
})
Append data to a dataset.
client.PushData(context.Background(), "sales.gross", geckoclient.Dataset{
DeleteBy: []string{"name"},
Data: []map[string]interface{}{
{
"amount": 300,
"name": "Waxon Butter",
"date": now.Format(isoTime),
},
{
"amount": 1300,
"name": "Shred Lack",
"date": now.Add(time.Hour * 30).Format(isoTime),
},
{
"amount": 500,
"name": "Creg Washer",
"date": now.Add(time.Hour * 10).Format(isoTime),
},
},
})
DeleteBy
is an optional field by which to order the truncation of records once the maximum record count has been reached. By default the oldest records (by insertion time) will be removed.
Vendoring is done with Govendor.
- Fork it ( https://github.com/influx6/geckoclient/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request