metabaseutil

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ApiUrlDataset   = "/api/dataset"
	QueryTypeNative = "native"
)
View Source
const MaxPerPage = int64(2000)

Variables

This section is empty.

Functions

func GetTableBySQLName added in v0.1.0

func GetTableBySQLName(apiClient *metabase.APIClient, tableName string) (*metabase.Database, *metabase.DatabaseTable, error)

func NewApiClient

func NewApiClient(cfg mo.Config) (*metabase.APIClient, *mo.AuthResponse, error)

func NewApiClientEnv

func NewApiClientEnv(cfg *mo.ConfigEnvOpts) (*metabase.APIClient, *mo.AuthResponse, error)

func NewApiClientHttpClient

func NewApiClientHttpClient(mbBaseUrl string, httpClient *http.Client) *metabase.APIClient

func NewApiClientPasswordWithSessionId

func NewApiClientPasswordWithSessionId(serverURL, username, password, sessionId string, tlsSkipVerify bool) (*metabase.APIClient, *mo.AuthResponse, error)

func NewApiClientSessionId

func NewApiClientSessionId(serverUrl, token string, tlsSkipVerify bool) *metabase.APIClient

func QuerySQL

func QuerySQL(apiClient *metabase.APIClient, databaseID int64, sql string) (metabase.DatasetQueryResults, *http.Response, error)

func QuerySQLHttp

func QuerySQLHttp(httpClient *http.Client, baseURL string, databaseID int64, sql string) (*http.Response, error)

func SimpleQuery

func SimpleQuery(databaseId, tableId int64) metabase.DatasetQueryJsonQuery

func SqlResponseToTimeSeries added in v0.1.2

func SqlResponseToTimeSeries(seriesName string, sr *SqlResponse, countColIdx, timeColIdx int) (timeseries.TimeSeries, error)

Types

type AppConfig

type AppConfig struct {
	Config        string `short:"c" long:"config" description:"Config (cli,env)" required:"true"`
	URL           string `short:"u" long:"url" description:"The base URL" required:"false"`
	Username      string `short:"n" long:"username" description:"The username" required:"false"`
	Password      string `short:"p" long:"password" description:"The password" required:"false"`
	SessionId     string `short:"s" long:"sessionid" description:"The sessionId" required:"false"`
	TlsSkipVerify bool
}

func (*AppConfig) GetClient

func (opts *AppConfig) GetClient() (*metabase.APIClient, *mo.AuthResponse, error)

type Record

type Record struct {
	Columns []metabase.DatasetQueryResultsMetadataColumn
	Cols    []string
	Row     []interface{}
	Related []Record
}

func (*Record) GetString

func (rec *Record) GetString(key string) (string, error)

func (*Record) GetStringOrEmpty

func (rec *Record) GetStringOrEmpty(key string) string

func (*Record) GetTime

func (rec *Record) GetTime(key, format string) (time.Time, error)

type Records

type Records struct {
	Columns []metabase.DatasetQueryResultsMetadataColumn
	Cols    []string
	Rows    [][]interface{}
}

func GetAllRecords

func GetAllRecords(apiClient *metabase.APIClient, opts metabase.DatasetQueryJsonQuery) (Records, error)

func GetAllRecordsSimple

func GetAllRecordsSimple(apiClient *metabase.APIClient, databaseId, tableId int64) (Records, error)

func NewRecordsFromJsonFile

func NewRecordsFromJsonFile(file string) (Records, error)

func (*Records) FilterRecordsString

func (recs *Records) FilterRecordsString(key, val string) RecordsSet

func (*Records) FilterRecordsStringOr

func (recs *Records) FilterRecordsStringOr(key string, vals []string) RecordsSet

func (*Records) InflateRecord

func (recs *Records) InflateRecord(rec []interface{}) Record

func (*Records) RecordsSet

func (recs *Records) RecordsSet() RecordsSet

type RecordsSet

type RecordsSet struct {
	Records []Record
}

func (*RecordsSet) Distinct

func (recs *RecordsSet) Distinct(key string) RecordsSet

func (*RecordsSet) FilterRecordsString

func (recs *RecordsSet) FilterRecordsString(key, val string) RecordsSet

type SQLInfo

type SQLInfo struct {
	Name        string
	DatabaseID  int64
	SQL         string
	SQLFormat   string
	SQLVars     []interface{}
	ColIdxCount int
	ColIdxTime  int
}

SQLInfo holds the information for a SQL query.

func (*SQLInfo) Inflate

func (sqli *SQLInfo) Inflate()

Inflate expands data.

func (*SQLInfo) NativeSQL

func (sqli *SQLInfo) NativeSQL() string

NativeSQL returns a formatted or raw SQL statement.

func (*SQLInfo) Validate

func (sqli *SQLInfo) Validate(checkColUnique bool) error

Validate checks the parameter information before the query is performed.

type SqlData

type SqlData struct {
	Rows [][]interface{} `json:"rows,omitempty"`
}

type SqlResponse

type SqlResponse struct {
	Data SqlData `json:"data,omitempty"`
}

func NewSqlResponse

func NewSqlResponse(bytes []byte) (*SqlResponse, error)

func NewSqlResponseHttp

func NewSqlResponseHttp(resp *http.Response) (*SqlResponse, error)

func QuerySQLHttpMore

func QuerySQLHttpMore(httpClient *http.Client, baseURL string, databaseID int64, sql string) (*SqlResponse, *http.Response, error)

func QuerySQLInfo added in v0.1.0

func QuerySQLInfo(httpClient *http.Client, baseURL string, opts SQLInfo) (*SqlResponse, error)

QuerySQLInfo executes a raw SQL query

func QuerySQLInfoTimeSeries added in v0.1.2

func QuerySQLInfoTimeSeries(httpClient *http.Client, baseURL string, opts SQLInfo) (*timeseries.TimeSeries, *SqlResponse, error)

QuerySQLInfoTimeSeries executes a raw SQL query that is designed to provide counts by date.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL