Documentation ¶
Overview ¶
Package api provides a low-level client to the overkiz api JSON responses are not unmarshalled and are returned as-is.
Index ¶
- type AuthenticationError
- type Client
- func (c *Client) DoWithAuth(req *http.Request) (*http.Response, error)
- func (c *Client) Execute(json []byte) (*http.Response, error)
- func (c *Client) GetActionGroups() (*http.Response, error)
- func (c *Client) GetDevice(deviceURL string) (*http.Response, error)
- func (c *Client) GetDeviceState(deviceURL, stateName string) (*http.Response, error)
- func (c *Client) GetDevices() (*http.Response, error)
- func (c *Client) GetWithAuth(query string) (*http.Response, error)
- func (c *Client) ListenerID() string
- func (c *Client) Login() error
- func (c *Client) PollEvents() (*http.Response, error)
- func (c *Client) RefreshStates() error
- func (c *Client) SessionID() string
- func (c *Client) SetListenerID(listenerID string)
- type JSONError
- type NoRegisteredEventListenerError
- type TooManyRequestsError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationError ¶
AuthenticationError contains an http error Code and text Message
func NewAuthenticationError ¶
func NewAuthenticationError(message string) *AuthenticationError
NewAuthenticationError creates a new AuthenticationError
func (*AuthenticationError) Error ¶
func (e *AuthenticationError) Error() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to make http requests to the api server while making the authentification and session ID renewal transparent.
func NewWithHTTPClient ¶
func NewWithHTTPClient(username, password, baseURL, sessionID string, hc *http.Client) (*Client, error)
NewWithHTTPClient returns a new Client, injecting the HTTP client to use. See New.
func (*Client) DoWithAuth ¶
DoWithAuth performs the given request. If an authentication error occurs, it tries to login to renew the sessionID, then tries the request again.
func (*Client) Execute ¶
Execute initiates the execution of a group of actions json needs to be marshalled from an ActionGroup
func (*Client) GetActionGroups ¶
GetActionGroups returns the list of action groups defined on the box
func (*Client) GetDeviceState ¶
GetDeviceState returns the current state with name for the device with URL deviceURL
func (*Client) GetDevices ¶
GetDevices returns the raw response to retrieving all devices
func (*Client) GetWithAuth ¶
GetWithAuth performs a GET request for the given query which is appended to the baseURL. It tries to renew the session ID if needed.
func (*Client) ListenerID ¶
ListenerID returns the stored listenerID.
func (*Client) Login ¶
Login to the api server to obtain a session ID cookie This is normally called automatically from the methods that need it
func (*Client) PollEvents ¶
PollEvents checks for events, using the saved listener and refreshing it if needed
func (*Client) RefreshStates ¶
RefreshStates tells the server send the state of all devices as events
func (*Client) SessionID ¶
SessionID is the latest known sessionID value It can be used for caching sessions externally. Returns an empty string if the session cookie is not set
func (*Client) SetListenerID ¶
SetListenerID overrides the stored listenerID.
type NoRegisteredEventListenerError ¶
NoRegisteredEventListenerError happens when an event poll is done on an invalid event listener id
func NewNoRegisteredEventListenerError ¶
func NewNoRegisteredEventListenerError(message string) *NoRegisteredEventListenerError
NewNoRegisteredEventListenerError creates a new TooManyRequestsError
func (*NoRegisteredEventListenerError) Error ¶
func (e *NoRegisteredEventListenerError) Error() string
type TooManyRequestsError ¶
TooManyRequestsError is returned when the Login call gets a reject from the API server because too many authentication attempts too place in a short period. In this case a pause needs to be observed before trying again.
func NewTooManyRequestsError ¶
func NewTooManyRequestsError(message string) *TooManyRequestsError
NewTooManyRequestsError creates a new TooManyRequestsError
func (*TooManyRequestsError) Error ¶
func (e *TooManyRequestsError) Error() string