Documentation ¶
Overview ¶
Package cube implements a simple client for Cube.
Index ¶
Constants ¶
const ( Order_Asc Order = "asc" Order_Desc Order = "desc" // Boolean logical operators currently unsupported: https://cube.dev/docs/query-format#filters-operators Operator_Equals Operator = "equals" Operator_NotEquals Operator = "notEquals" Operator_Contains Operator = "contains" Operator_NotContains Operator = "notContains" Operator_GreaterThan Operator = "gt" Operator_GreaterThanOrEqualTo Operator = "gte" Operator_LessThan Operator = "lt" Operator_LessThanOrEqualTo Operator = "lte" Operator_Set Operator = "set" Operator_NotSet Operator = "notSet" Operator_InDateRange Operator = "inDateRange" Operator_NotInDateRange Operator = "notInDateRange" Operator_BeforeDate Operator = "beforeDate" Operator_AfterDate Operator = "afterDate" Granularity_Second Granularity = "second" Granularity_Minute Granularity = "minute" Granularity_Hour Granularity = "hour" Granularity_Day Granularity = "day" Granularity_Week Granularity = "week" Granularity_Month Granularity = "month" Granularity_Quarter Granularity = "quarter" Granularity_Year Granularity = "year" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenGenerator ¶
AccessTokenGenerator defines the interface for specifying access tokens which should be included in authenticated requests to the Cube server.
type AccessTokenGeneratorFunc ¶
AccessTokenGeneratorFunc defines a simple concrete type which can satisfy the AccessTokenGenerator interface. This type is only one of many options, and users may define their own implementations of the interface.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for interacting with Cube. Clients can be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines.
func NewClient ¶
func NewClient(cubeURL url.URL, tokenGenerator AccessTokenGenerator) *Client
NewClient creates a new Cube client. The optional tokenGenerator can be used to include an API token with the Cube requests.
func (*Client) Load ¶
func (c *Client) Load(ctx context.Context, query Query, results interface{}) (ResponseMetadata, error)
Load fetches JSON-encoded data from the Cube API and stores the result in the value pointed to by `results`. If `results` is nil or not a pointer, Load returns an error. Load uses the decodings that json.Unmarshal uses, allocating maps, slices, and pointers as necessary.
type DateRange ¶
DateRange represents the (string|[]string) date range type in the Cube query format. https://cube.dev/docs/query-format https://cube.dev/docs/@cubejs-client-core#date-range
This is a union type and only one field should be set.
func RelativeDateRange ¶
RelativeDateRange returns a DateRange with the RelativeRange field set to the input string Example arguments: "last 7 days", "this month", "1 hour ago"
func (DateRange) MarshalJSON ¶
MarshalJSON marshals the input DateRange object; only one of the fields (i.e. RelativeRange, AbsoluteRange) will be marshalled as a top-level JSON value, depending on which is set.
type Filter ¶
type Granularity ¶
type Granularity string
https://cube.dev/docs/@cubejs-client-core#types-time-dimension-granularity
type Operator ¶
type Operator string
https://cube.dev/docs/@cubejs-client-core#types-filter-operator
type OrderTuple ¶
func (OrderTuple) MarshalJSON ¶
func (t OrderTuple) MarshalJSON() ([]byte, error)
func (*OrderTuple) UnmarshalJSON ¶
func (t *OrderTuple) UnmarshalJSON(byts []byte) error
type Query ¶
type Query struct { Measures []string `json:"measures,omitempty"` TimeDimensions []TimeDimension `json:"timeDimensions,omitempty"` Order []OrderTuple `json:"order,omitempty"` Limit int `json:"limit,omitempty"` Filters []Filter `json:"filters,omitempty"` Dimensions []string `json:"dimensions,omitempty"` Ungrouped bool `json:"ungrouped"` }
Query represents a query that can be issued to a Cube server via the client.
type ResponseMetadata ¶
type ResponseMetadata struct { Query interface{} `json:"query"` Annotation interface{} `json:"annotation"` }
ResponseMetadata returns metadata that appears in the response from the Cube API that is not the requested data.
type TimeDimension ¶
type TimeDimension struct { Dimension string `json:"dimension"` DateRange DateRange `json:"dateRange"` Granularity Granularity `json:"granularity,omitempty"` }