Documentation
¶
Overview ¶
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
Index ¶
- func CheckResponse(r *http.Response) error
- type AccessToken
- type DebugConsole
- type Device
- type DevicesService
- func (s *DevicesService) Claim(coredId string) (*http.Response, error)
- func (s *DevicesService) Exec(coreId, funcName, params string) (ExecResponse, *http.Response, error)
- func (s *DevicesService) Info(coreId string) (Info, *http.Response, error)
- func (s *DevicesService) List() ([]Device, *http.Response, error)
- func (s *DevicesService) Read(coreId, varName string) (ReadResponse, *http.Response, error)
- func (s *DevicesService) Rename(coreId, name string) (*http.Response, error)
- type Error
- type ErrorResponse
- type ExecResponse
- type Info
- type ReadResponse
- type SparkClient
- type Token
- type TokensService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type AccessToken ¶
type AccessToken struct { Value string `json:"access_token,omitempty"` Type string `json:"token_type,omitempty"` ExpiresIn uint32 `json:"expires_in,omitempty"` }
func (AccessToken) String ¶
func (a AccessToken) String() string
type DebugConsole ¶
type DebugConsole struct { }
type Device ¶
type DevicesService ¶
type DevicesService struct {
// contains filtered or unexported fields
}
func (*DevicesService) Claim ¶
func (s *DevicesService) Claim(coredId string) (*http.Response, error)
func (*DevicesService) Exec ¶
func (s *DevicesService) Exec(coreId, funcName, params string) (ExecResponse, *http.Response, error)
func (*DevicesService) Read ¶
func (s *DevicesService) Read(coreId, varName string) (ReadResponse, *http.Response, error)
type Error ¶
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message Errors []Error `json:"errors"` // more detail on individual errors }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ExecResponse ¶
type ReadResponse ¶
type SparkClient ¶
type SparkClient struct { // Base URL for API requests. Defaults to the public Spark cloud API, but can be // set to a domain endpoint to use with hosted cloud platform. BaseURL should // always be specified with a trailing slash. BaseURL *url.URL // User agent used when communicating with the Spark.io API. UserAgent string AuthToken string // Services used for talking to different parts of the Spark cloud API. Devices *DevicesService Tokens *TokensService // contains filtered or unexported fields }
A SparkClient manages communication with the Spark API.
func NewClient ¶
func NewClient(httpClient *http.Client, timeout time.Duration) *SparkClient
NewClient returns a new Spark API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the goauth2 library).
func (*SparkClient) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*SparkClient) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the SparkClient. Relative URLs should always be specified without a preceding slash.
type Token ¶
type TokensService ¶
type TokensService struct {
// contains filtered or unexported fields
}
func (*TokensService) Delete ¶
func (s *TokensService) Delete(token, username, password string) (*http.Response, error)
func (*TokensService) Login ¶
func (s *TokensService) Login(username, password string) (AccessToken, *http.Response, error)