Documentation
¶
Overview ¶
The redash package implements a simple client and wrapper library for Redash REST api.
GET/POST/DELETE is accepted.
Original client is made by implement Interface.
Summary of use case.
Case 1:
Get/Post/Delete directory.
Case 2:
implement your Interface and GetInter/PostInter/DeleteInter with new Client.
Case 3:
Queries.GetQuery/(other func in Queries)
Index ¶
- Variables
- func Delete(sub string, params map[string]string) (resp *http.Response, err error)
- func DeleteInter(client Interface, sub string, params map[string]string) (resp *http.Response, err error)
- func Do(method, sub string, opts *Options) (resp *http.Response, err error)
- func DoInter(client Interface, method, sub string, opts *Options) (resp *http.Response, err error)
- func Get(sub string, params map[string]string) (resp *http.Response, err error)
- func GetInter(client Interface, sub string, params map[string]string) (resp *http.Response, err error)
- func Post(sub string, jsonBody []byte) (resp *http.Response, err error)
- func PostInter(client Interface, sub string, jsonBody []byte) (resp *http.Response, err error)
- func Request(method, sub string, opts *Options) (req *http.Request, err error)
- func RequestInter(client Interface, method, sub string, opts *Options) (req *http.Request, err error)
- type Apikeyer
- type ClientData
- type Column
- type DefaultClientData
- type DefaultOptser
- type FormatQuery
- type HTTPClienter
- type Interface
- type Job
- type JobInner
- type NewQuery
- type Options
- type PagingResponseQuery
- type QueriesS
- func (qs QueriesS) DeleteJog(jobId string) (r io.Reader, err error)
- func (qs QueriesS) DeleteQuery(queryId int) (r io.Reader, err error)
- func (qs QueriesS) GetJob(jobId string) (r io.Reader, err error)
- func (qs QueriesS) GetMy(pageSize, page int) (r io.Reader, err error)
- func (qs QueriesS) GetQuery(pageSize, page int) (r io.Reader, err error)
- func (qs QueriesS) GetQueryId(queryId int) (r io.Reader, err error)
- func (qs QueriesS) GetQueryResults(queryResultId int) (r io.Reader, err error)
- func (qs QueriesS) GetRecent() (r io.Reader, err error)
- func (qs QueriesS) GetResultsById(queryId, queryResultId int, filetype string) (r io.Reader, err error)
- func (qs QueriesS) GetResultsByQueryId(queryId int, filetype string) (r io.Reader, err error)
- func (qs QueriesS) GetSearch(q string) (r io.Reader, err error)
- func (qs QueriesS) PostFork(queryId int) (r io.Reader, err error)
- func (qs QueriesS) PostFormat(sql string) (r io.Reader, err error)
- func (qs QueriesS) PostQuery(newQuery NewQuery) (res io.Reader, err error)
- func (qs QueriesS) PostQueryId(queryId int, newQuery NewQuery) (r io.Reader, err error)
- func (qs QueriesS) PostQueryResult(query string, maxAge, dataSourceId int) (r io.Reader, err error)
- func (qs QueriesS) PostRefresh(queryId int) (r io.Reader, err error)
- func (q QueriesS) Queries(s string) (rs string)
- type Querieser
- type QueryResult
- type ResponseQuery
- type Result
- type ResultData
- type Row
- type Urler
Constants ¶
This section is empty.
Variables ¶
var (
DefaultClient = NewDefaultClient()
)
var Queries = &QueriesS{DefaultClient}
Default Queries
Functions ¶
func DeleteInter ¶
func DeleteInter(client Interface, sub string, params map[string]string) (resp *http.Response, err error)
DeleteInter do Redash DELETE with Interface and return result.
func GetInter ¶
func GetInter(client Interface, sub string, params map[string]string) (resp *http.Response, err error)
GetInter do Redash GET with Interface and return result.
Types ¶
type Column ¶
type Column struct { FriendlyName string `json:"friendly_name"` Type string `json:"type"` Name string `json:"name"` }
Wrap Redash column for result data.
type DefaultClientData ¶
type DefaultClientData struct { ClientData // contains filtered or unexported fields }
Default implement of client. This is provided as DefaultClient.
func (DefaultClientData) Apikey ¶
func (dc DefaultClientData) Apikey() (apikey string, err error)
Implementation of apikey for DefaultClient
func (DefaultClientData) DefaultOpts ¶
func (dc DefaultClientData) DefaultOpts() *Options
Implementation of DefaultOpts for DefaultClient
func (DefaultClientData) HTTPClient ¶
func (dc DefaultClientData) HTTPClient() *http.Client
Implementation of HTTPClient for DefaultClient
type DefaultOptser ¶
type DefaultOptser interface {
DefaultOpts() *Options
}
DefaultOpts is default options for request.
type FormatQuery ¶
type FormatQuery struct {
Query string `json:"query"`
}
Wrap Redash format query.
type HTTPClienter ¶
HTTPClient is HTTP client to do request.
type Interface ¶
type Interface interface { Urler Apikeyer HTTPClienter DefaultOptser }
A type, for original client, that sufisfies redash.Interface can use GetInter, PostInter, DeleteInter methods. If want to change apikey management, Httpclient and so on, just implement methods of this Interface.
type JobInner ¶
type JobInner struct { Status int `json:"status"` Error string `json:"error"` Id string `json:"id"` QueryResultId int `json:"query_result_id"` Updated_at int `json:"updated_at"` }
Wrap Redash job detail.
type NewQuery ¶
type NewQuery struct { DataSourceId int `json:"data_source_id"` Query string `json:"query"` Name string `json:"name"` Description string `json:"description"` Schedule string `json:"schedule"` Options map[string]string `json:"options"` }
Wrap Redash new query.
type PagingResponseQuery ¶
type PagingResponseQuery struct { Count int `json:"count"` Page int `json:"page"` PageSize int `json:"page_size"` Results []ResponseQuery `json:"results"` }
Wrap Redash paging response query.
type QueriesS ¶
type QueriesS struct {
Client Interface
}
Default struct for queries.
func (QueriesS) DeleteQuery ¶
Wrap Redash api DELETE queries.
func (QueriesS) GetQueryId ¶
Wrap Redash api GET queries/${query id}.
func (QueriesS) GetQueryResults ¶
Wrap Redash api GET querie_results.
func (QueriesS) GetResultsById ¶
func (qs QueriesS) GetResultsById(queryId, queryResultId int, filetype string) (r io.Reader, err error)
Wrap Redash api GET ${query id}/results/${query resut id}.${filetype}
func (QueriesS) GetResultsByQueryId ¶
Wrap Redash api GET ${query id}/results.${filetype}.
func (QueriesS) PostFormat ¶
Wrap Redash api POST format.
func (QueriesS) PostQueryId ¶
Wrap Redash api POST queries.
func (QueriesS) PostQueryResult ¶
Wrap Redash api POST query_results.
func (QueriesS) PostRefresh ¶
Wrap Redash api POST refresh.
type QueryResult ¶
type QueryResult struct { RetrievedAt string `json:"retrieved_at"` QueryHash string `json:"query_hash"` Query string `json:"query"` Runtime float64 `json:"runtime"` Data ResultData `json:"data"` Id int `json:"id"` DataSourceId int `json:"data_source_id"` }
Wrap Redash query result.
type ResponseQuery ¶
type ResponseQuery struct { Id int `json:"id"` LatestQueryDataId int `json:"latest_query_data_id"` Name string `json:"name"` Description string `json:"description"` Query string `json:"query"` QueryHash string `json:"query_hash"` Schedule string `json:"schedule"` ApiKey string `json:"api_key"` IsArchived bool `json:"is_archived"` IsDraft bool `json:"is_draft"` UpdatedAt string `json:"updated_at"` CreatedAt string `json:"created_at"` DataSourceId int `json:"data_source_id"` Options Options `json:"options"` Version int `json:"version"` UserId int `json:"user_id"` LastModifiedById int `json:"last_modified_by_id"` RetrivedAt string `json:"retrieved_at"` Runtime int `json:"runtime"` }
Wrap Redash response query.
type Result ¶
type Result struct {
QueryResult QueryResult `json:"query_result"`
}
Wrap Redash result.
type ResultData ¶
Wrap Redash result data.