Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Spark

This is a go wrapper (CLI + API client) to the spark.io API.

Why another incomplete CLI?

The spark team has released spark-cli which is based on nodeJS and distributed via npm. This CLI aims to eventually be a full replacement for spark-cli.

CLI example usage

$ spark
usage: spark [--help] <command> [<args>]

Available commands are:
    claim         Claims a spark core
    devices       Lists devices for authenticated user
    exec          Calls a function exposed by the core
    info          Displays basic information about the given Core
    invalidate    Invalidates an access token. Requires username/password
    login         Log in to spark cloud
    logout        Logout from spark cloud
    read          Reads the value of variables exposed by the spark core
    rename        Renames a core
    tokens        List all access tokens. Requires username/password

For example, to rename your core:

$ spark -v
spark v0.1.2
Using spark cloud API v1

$ spark devices
Error connecting to Spark cloud: You should login first.

$ spark login
Username:  me@example.com
Password: 
Successfully logged in. Access token persisted to: ~/.sparkio

$ spark devices
- Device: spork [53dd73045076535132181487], connected?: false

$ spark rename 53dd73045076535132181487 new_name
Successfully renamed core 53dd73045076535132181487 to new_name


$ spark info 53dd73045076535132181487
Info for spork [53dd73045076535132181487]
Variables:
 - temperature : int32
 - hello : string
Functions:
 - led
 - temp

$ spark read 53dd73045076535132181487 temperature
temperature = 120.000000

$ spark exec 53dd73045076535132181487 temp 90
Command “temp” with arguments “90” was successfully executed on core spork[53dd73045076535132181487].

API Client example usage

client := spark.NewClient(nil)
token, resp, err := client.Tokens.Login(username, password)

devices, resp, err := client.Devices.List()
resp, err := client.Devices.Claim(coreId)

resp, err := client.Devices.Rename(coreId, new_name)

TODO

  • add version
  • add tests
  • document the spark API endpoints

Thanks

About

CLI + API http wrapper written in go for the Spark.io API

Resources

License

Languages

You can’t perform that action at this time.