Documentation ¶
Index ¶
- Variables
- func NewRequest(url string, options ...Option) (*http.Response, error)
- func ReadResponseBody(response *http.Response) ([]byte, error)
- type BackdropResponse
- type Dashboard
- type Dashboards
- type DataClient
- type DataSource
- type MetaClient
- type Module
- type Option
- type Organisation
- type QueryParams
- type RequestOptions
- type Tab
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is an error indicating that the server returned a 404. ErrNotFound = errors.New("not found") // ErrBadRequest is an error indicating that the client request had a problem. ErrBadRequest = errors.New("bad request") )
Functions ¶
func NewRequest ¶
NewRequest tries to make a request to the URL, returning the http.Response if it was successful, or an error if there was a problem. Optional Option arguments can be passed to specify contextual behaviour for this request. See MaxElapsedTime.
Types ¶
type BackdropResponse ¶
type BackdropResponse struct { Data json.RawMessage `json:"data"` Warning string `json:"warning,omitempty"` Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` }
BackdropResponse is a response from the Backdrop Read API
type Dashboard ¶
type Dashboard struct { Department Organisation `json:"department"` Agency Organisation `json:"agency,omitempty"` DashboardType string `json:"dashboard-type"` Slug string `json:"slug"` Title string `json:"title"` Description string `json:"description"` Modules []Module `json:"modules"` Published bool `json:"published"` PageType string `json:"page-type"` Costs string `json:"costs"` }
Dashboard represents a collection of modules for a given organisation
type Dashboards ¶
type Dashboards struct {
Items []Dashboard `json:"Items"`
}
Dashboards is a collection of Dashboard instances
type DataClient ¶
type DataClient interface { // BuildURL creates the URL to make a request to the read API BuildURL(dataGroup, dataType string, dataQuery QueryParams) string // Fetch makes a request to the read API and returns a non-nil BackdropResponse or an error Fetch(dataGroup, dataType string, dataQuery QueryParams) (*BackdropResponse, error) }
DataClient is a client for the Backdrop Read API
func NewDataClient ¶
func NewDataClient(url string, logger *logrus.Logger, options ...Option) DataClient
NewDataClient creates a new DataClient for talking to the Read API
type DataSource ¶
type DataSource struct { DataGroup string `json:"data-group"` DataType string `json:"data-type"` QueryParams QueryParams `json:"query-params"` }
DataSource is the data source for a module
type MetaClient ¶
type MetaClient interface { Fetch(slug string) (Dashboard, error) FetchDashboards() (Dashboards, error) }
MetaClient defines the interface that we need to talk to the meta data API
func NewMetaClient ¶
func NewMetaClient(baseURL string, log *logrus.Logger) MetaClient
NewMetaClient returns a new MetaClient implementation with sensible defaults.
type Module ¶
type Module struct { Info []string `json:"info"` DataSource DataSource `json:"data-source"` Tabs []Tab `json:"tabs"` Title string `json:"title"` }
Module represents a visualisation with a Dashboard
type Option ¶
type Option func(*http.Request, *RequestOptions) Option
Option is a self-referential function used to configure a RequestOptions struct. See http://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html
func BearerToken ¶
BearerToken sets the Authorization header for a request
func MaxElapsedTime ¶
MaxElapsedTime specifies the maximum duration that we should use to retry requests to the origin server. The default value is 5 seconds.
type Organisation ¶
Organisation represents a government organisational unit, such as department or agency
type QueryParams ¶
type QueryParams struct { FilterBy []string `json:"filter_by,omitempty" url:"filter_by,omitempty"` FilterByPrefix []string `json:"filter_by_prefix,omitempty" url:"filter_by_prefix,omitempty"` GroupBy []string `json:"group_by,omitempty" url:"group_by,omitempty"` Collect []string `json:"collect,omitempty" url:"collect,omitempty"` SortBy string `json:"sort_by,omitempty" url:"sort_by,omitempty"` Duration int `json:"duration,omitempty" url:"duration,omitempty"` Period string `json:"period,omitempty" url:"period,omitempty"` Limit int `json:"limit,omitempty" url:"limit,omitempty"` StartAt time.Time `json:"start_at,omitempty" url:"start_at,omitempty"` EndAt time.Time `json:"end_at,omitempty" url:"end_at,omitempty"` }
QueryParams represents the possible parameters that the Backdrop RPC read API supports
type RequestOptions ¶
type RequestOptions struct { // MaxElapsedTime is the duration allowed to try to get a response from the origin server. MaxElapsedTime time.Duration }
RequestOptions is the container for tweaking how NewRequest functions.
type Tab ¶
type Tab struct { Description string `json:"description"` DataSource DataSource `json:"data-source"` }
Tab is a UI construct exposed within the meta data API