spark

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2014 License: BSD-3-Clause Imports: 4 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
This spark client is heavily inspired by https://github.com/google/go-github The Github client is distributed under the BSD-style license found at: https://github.com/google/go-github/blob/master/LICENSE Due to a lack of exhaustive API documentation on http://docs.spark.io some error responses might not match the current ErrorResponse implementation
This spark client is heavily inspired by https://github.com/google/go-github The Github client is distributed under the BSD-style license found at: https://github.com/google/go-github/blob/master/LICENSE Due to a lack of exhaustive API documentation on http://docs.spark.io some error responses might not match the current ErrorResponse implementation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL