Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadError ¶
ReadError reads the response body and returns it as an error string. It also closes the body.
func ReadJSON ¶
ReadJSON reads the response body and decodes it into v. It also closes the body. Returns an error with the body text on non-2xx status.
func SetBuildInfo ¶
func SetBuildInfo(version, commit, buildTime string)
SetBuildInfo sets build-time info from ldflags.
Types ¶
type Client ¶
type Client struct {
BaseURL string
HTTPClient *http.Client
// contains filtered or unexported fields
}
Client wraps HTTP calls to the sandbox API.
type Config ¶
type Config struct {
Server string `json:"server"`
LoginToken string `json:"login_token"`
AccessToken string `json:"access_token,omitempty"`
AccessExp *time.Time `json:"access_token_exp,omitempty"`
}
Config holds persisted CLI state.
func LoadConfig ¶
LoadConfig reads config from disk. Returns zero Config if file doesn't exist.
func (Config) HasValidAccessToken ¶
HasValidAccessToken returns true if the access token exists and hasn't expired.
type LoginResponse ¶
type LoginResponse struct {
AccessToken string `json:"access_token"`
AccessTokenExp *time.Time `json:"access_token_exp"`
}
LoginResponse is the response from GET /api/v1/login.
func Login ¶
func Login(baseURL, loginToken string) (*LoginResponse, error)
Login exchanges a login token for an access token.
Click to show internal directories.
Click to hide internal directories.