Categorygithub.com/pims/spark
modulepackage
0.1.2
Repository: https://github.com/pims/spark.git
Documentation: pkg.go.dev

# 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:  [email protected]
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

# Packages

No description provided by the author
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.

# Constants

The main version number that is being run at the moment.

# Variables

Commands is the mapping of all the available Spark commands.